├── img ├── res.png └── unity-games.png ├── CONTRIBUTING.md ├── LICENSE ├── CODE_INTERMEDIATE.md ├── CODE_BASICS.md └── README.md /img/res.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/proyecto26/awesome-unity/HEAD/img/res.png -------------------------------------------------------------------------------- /img/unity-games.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/proyecto26/awesome-unity/HEAD/img/unity-games.png -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Code of Conduct 9 | 10 | ### Our Pledge 11 | 12 | In the interest of fostering an open and welcoming environment, we as 13 | contributors and maintainers pledge to making participation in our project and 14 | our community a harassment-free experience for everyone, regardless of age, body 15 | size, disability, ethnicity, gender identity and expression, level of experience, 16 | nationality, personal appearance, race, religion, or sexual identity and 17 | orientation. 18 | 19 | ### Our Standards 20 | 21 | Examples of behavior that contributes to creating a positive environment 22 | include: 23 | 24 | * Using welcoming and inclusive language 25 | * Being respectful of differing viewpoints and experiences 26 | * Gracefully accepting constructive criticism 27 | * Focusing on what is best for the community 28 | * Showing empathy towards other community members 29 | 30 | Examples of unacceptable behavior by participants include: 31 | 32 | * The use of sexualized language or imagery and unwelcome sexual attention or 33 | advances 34 | * Trolling, insulting/derogatory comments, and personal or political attacks 35 | * Public or private harassment 36 | * Publishing others' private information, such as a physical or electronic 37 | address, without explicit permission 38 | * Other conduct which could reasonably be considered inappropriate in a 39 | professional setting 40 | 41 | ### Our Responsibilities 42 | 43 | Project maintainers are responsible for clarifying the standards of acceptable 44 | behavior and are expected to take appropriate and fair corrective action in 45 | response to any instances of unacceptable behavior. 46 | 47 | Project maintainers have the right and responsibility to remove, edit, or 48 | reject comments, commits, code, wiki edits, issues, and other contributions 49 | that are not aligned to this Code of Conduct, or to ban temporarily or 50 | permanently any contributor for other behaviors that they deem inappropriate, 51 | threatening, offensive, or harmful. 52 | 53 | ### Scope 54 | 55 | This Code of Conduct applies both within project spaces and in public spaces 56 | when an individual is representing the project or its community. Examples of 57 | representing a project or community include using an official project e-mail 58 | address, posting via an official social media account, or acting as an appointed 59 | representative at an online or offline event. Representation of a project may be 60 | further defined and clarified by project maintainers. 61 | 62 | ### Enforcement 63 | 64 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 65 | reported by contacting the project team at jdnichollsc@hotmail.com. All 66 | complaints will be reviewed and investigated and will result in a response that 67 | is deemed necessary and appropriate to the circumstances. The project team is 68 | obligated to maintain confidentiality with regard to the reporter of an incident. 69 | Further details of specific enforcement policies may be posted separately. 70 | 71 | Project maintainers who do not follow or enforce the Code of Conduct in good 72 | faith may face temporary or permanent repercussions as determined by other 73 | members of the project's leadership. 74 | 75 | ### Attribution 76 | 77 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 78 | available at [http://contributor-covenant.org/version/1/4][version] 79 | 80 | [homepage]: http://contributor-covenant.org 81 | [version]: http://contributor-covenant.org/version/1/4/ 82 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | CC0 1.0 Universal 2 | 3 | Statement of Purpose 4 | 5 | The laws of most jurisdictions throughout the world automatically confer 6 | exclusive Copyright and Related Rights (defined below) upon the creator and 7 | subsequent owner(s) (each and all, an "owner") of an original work of 8 | authorship and/or a database (each, a "Work"). 9 | 10 | Certain owners wish to permanently relinquish those rights to a Work for the 11 | purpose of contributing to a commons of creative, cultural and scientific 12 | works ("Commons") that the public can reliably and without fear of later 13 | claims of infringement build upon, modify, incorporate in other works, reuse 14 | and redistribute as freely as possible in any form whatsoever and for any 15 | purposes, including without limitation commercial purposes. These owners may 16 | contribute to the Commons to promote the ideal of a free culture and the 17 | further production of creative, cultural and scientific works, or to gain 18 | reputation or greater distribution for their Work in part through the use and 19 | efforts of others. 20 | 21 | For these and/or other purposes and motivations, and without any expectation 22 | of additional consideration or compensation, the person associating CC0 with a 23 | Work (the "Affirmer"), to the extent that he or she is an owner of Copyright 24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work 25 | and publicly distribute the Work under its terms, with knowledge of his or her 26 | Copyright and Related Rights in the Work and the meaning and intended legal 27 | effect of CC0 on those rights. 28 | 29 | 1. Copyright and Related Rights. A Work made available under CC0 may be 30 | protected by copyright and related or neighboring rights ("Copyright and 31 | Related Rights"). Copyright and Related Rights include, but are not limited 32 | to, the following: 33 | 34 | i. the right to reproduce, adapt, distribute, perform, display, communicate, 35 | and translate a Work; 36 | 37 | ii. moral rights retained by the original author(s) and/or performer(s); 38 | 39 | iii. publicity and privacy rights pertaining to a person's image or likeness 40 | depicted in a Work; 41 | 42 | iv. rights protecting against unfair competition in regards to a Work, 43 | subject to the limitations in paragraph 4(a), below; 44 | 45 | v. rights protecting the extraction, dissemination, use and reuse of data in 46 | a Work; 47 | 48 | vi. database rights (such as those arising under Directive 96/9/EC of the 49 | European Parliament and of the Council of 11 March 1996 on the legal 50 | protection of databases, and under any national implementation thereof, 51 | including any amended or successor version of such directive); and 52 | 53 | vii. other similar, equivalent or corresponding rights throughout the world 54 | based on applicable law or treaty, and any national implementations thereof. 55 | 56 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, 57 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and 58 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright 59 | and Related Rights and associated claims and causes of action, whether now 60 | known or unknown (including existing as well as future claims and causes of 61 | action), in the Work (i) in all territories worldwide, (ii) for the maximum 62 | duration provided by applicable law or treaty (including future time 63 | extensions), (iii) in any current or future medium and for any number of 64 | copies, and (iv) for any purpose whatsoever, including without limitation 65 | commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes 66 | the Waiver for the benefit of each member of the public at large and to the 67 | detriment of Affirmer's heirs and successors, fully intending that such Waiver 68 | shall not be subject to revocation, rescission, cancellation, termination, or 69 | any other legal or equitable action to disrupt the quiet enjoyment of the Work 70 | by the public as contemplated by Affirmer's express Statement of Purpose. 71 | 72 | 3. Public License Fallback. Should any part of the Waiver for any reason be 73 | judged legally invalid or ineffective under applicable law, then the Waiver 74 | shall be preserved to the maximum extent permitted taking into account 75 | Affirmer's express Statement of Purpose. In addition, to the extent the Waiver 76 | is so judged Affirmer hereby grants to each affected person a royalty-free, 77 | non transferable, non sublicensable, non exclusive, irrevocable and 78 | unconditional license to exercise Affirmer's Copyright and Related Rights in 79 | the Work (i) in all territories worldwide, (ii) for the maximum duration 80 | provided by applicable law or treaty (including future time extensions), (iii) 81 | in any current or future medium and for any number of copies, and (iv) for any 82 | purpose whatsoever, including without limitation commercial, advertising or 83 | promotional purposes (the "License"). The License shall be deemed effective as 84 | of the date CC0 was applied by Affirmer to the Work. Should any part of the 85 | License for any reason be judged legally invalid or ineffective under 86 | applicable law, such partial invalidity or ineffectiveness shall not 87 | invalidate the remainder of the License, and in such case Affirmer hereby 88 | affirms that he or she will not (i) exercise any of his or her remaining 89 | Copyright and Related Rights in the Work or (ii) assert any associated claims 90 | and causes of action with respect to the Work, in either case contrary to 91 | Affirmer's express Statement of Purpose. 92 | 93 | 4. Limitations and Disclaimers. 94 | 95 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 96 | surrendered, licensed or otherwise affected by this document. 97 | 98 | b. Affirmer offers the Work as-is and makes no representations or warranties 99 | of any kind concerning the Work, express, implied, statutory or otherwise, 100 | including without limitation warranties of title, merchantability, fitness 101 | for a particular purpose, non infringement, or the absence of latent or 102 | other defects, accuracy, or the present or absence of errors, whether or not 103 | discoverable, all to the greatest extent permissible under applicable law. 104 | 105 | c. Affirmer disclaims responsibility for clearing rights of other persons 106 | that may apply to the Work or any use thereof, including without limitation 107 | any person's Copyright and Related Rights in the Work. Further, Affirmer 108 | disclaims responsibility for obtaining any necessary consents, permissions 109 | or other rights required for any use of the Work. 110 | 111 | d. Affirmer understands and acknowledges that Creative Commons is not a 112 | party to this document and has no duty or obligation with respect to this 113 | CC0 or use of the Work. 114 | 115 | For more information, please see 116 | 117 | -------------------------------------------------------------------------------- /CODE_INTERMEDIATE.md: -------------------------------------------------------------------------------- 1 | # Code Intermediate 2 | A list of intermediate topics working with C# in Unity 3 | 4 |
5 | Generic Lists 6 | 7 | ```csharp 8 | using UnityEngine; 9 | using System.Collections; 10 | using System.Collections.Generic; 11 | 12 | public class SceneController: MonoBehaviour { 13 | 14 | public List shapes; 15 | 16 | void Start() 17 | { 18 | shapes = new List { "circle", "square", "triangle", "octagon" }; 19 | shapes.Add("rectangle"); 20 | shapes.Insert(2, "diamond"); 21 | 22 | shapes.Sort(); 23 | var triangleShape = shapes.Find(s => s == "triangle"); 24 | } 25 | } 26 | ``` 27 |
28 |
29 | Dictionaries 30 | 31 | ```csharp 32 | using UnityEngine; 33 | using System.Collections; 34 | using System.Collections.Generic; 35 | 36 | public class SceneController: MonoBehaviour { 37 | public Dictionary shapeDictionary; 38 | 39 | void Start() 40 | { 41 | shapeDictionary = new Dictionary(); 42 | var shapeName = "Circle"; 43 | var circle = new Shape { Name = shapeName }; 44 | 45 | shapeDictionary.Add(shapeName, circle); 46 | } 47 | 48 | private void SetColorByName(string shapeName, Color color) 49 | { 50 | shapeDictionary[shapeName].SetColor(color); 51 | } 52 | 53 | void Update() 54 | { 55 | if (Input.GetKeyDown(KeyCode.C)) 56 | { 57 | SetColorByName("Circle", Color.red); 58 | } 59 | } 60 | } 61 | ``` 62 |
63 |
64 | Queues 65 | 66 | ```csharp 67 | using UnityEngine; 68 | using System.Collections; 69 | using System.Collections.Generic; 70 | 71 | public class EnemiesController: MonoBehaviour { 72 | public Queue enemyQueue; 73 | 74 | void Start() 75 | { 76 | enemyQueue = new Queue(); 77 | enemyQueue.Enqueue(new Enemy { Name = "Boss1" }); 78 | enemyQueue.Enqueue(new Enemy { Name = "Boss2" }); 79 | enemyQueue.Enqueue(new Enemy { Name = "Boss3" }); 80 | } 81 | 82 | public Enemy GetFirstEnemy() 83 | { 84 | if (enemyQueue.Count > 0) { 85 | var enemy = enemyQueue.Dequeue(); 86 | // Call any method if you want 87 | enemy.Animate(); 88 | return enemy; 89 | } 90 | Debug.Log("Enemy queue is empty"); 91 | return null; 92 | } 93 | } 94 | ``` 95 |
96 |
97 | Stacks 98 | 99 | ```csharp 100 | using UnityEngine; 101 | using System.Collections; 102 | using System.Collections.Generic; 103 | 104 | public class EnemiesController: MonoBehaviour { 105 | public Stack enemyStack; 106 | 107 | void Start() 108 | { 109 | enemyStack = new Stack(); 110 | enemyStack.Push(new Enemy { Name = "Final boss" }); 111 | enemyStack.Push(new Enemy { Name = "Superboss" }); 112 | enemyStack.Push(new Enemy { Name = "Miniboss" }); 113 | } 114 | 115 | public Enemy GetNextBoss() 116 | { 117 | if (enemyStack.Count > 0) { 118 | var enemy = enemyStack.Pop(); 119 | // Call any method if you want 120 | enemy.Animate(); 121 | return enemy; 122 | } 123 | Debug.Log("Final boss was killed"); 124 | return null; 125 | } 126 | } 127 | ``` 128 |
129 |
130 | Coroutines 131 | 132 | ```csharp 133 | using System.Collections; 134 | using System.Collections.Generic; 135 | using UnityEngine; 136 | 137 | public class TaskController : MonoBehaviour 138 | { 139 | public List tasks; 140 | private Coroutine runTasksRoutine; 141 | 142 | private IEnumerator ExecuteTasksInSeries() 143 | { 144 | foreach(var task in tasks) { 145 | task.doSomething(); 146 | // Delay before execute next task 147 | yield return new WaitForSeconds(2); 148 | task.doSomethingElse(); 149 | // Other delay options 150 | // WaitUntil() 151 | // WaitWhile() 152 | // WaitForEndOfFrame() 153 | // WaitForFixedUpdate() 154 | // WaitForSecondsRealtime() 155 | } 156 | // Pause the game 157 | Time.timeScale = 0; 158 | yield return new WaitForSecondsRealtime(1); 159 | Debug.Log("I just wasted for a second, it's not affected by scaled time"); 160 | } 161 | 162 | void Start() 163 | { 164 | tasks = new List(); 165 | // Add your tasks here 166 | runTasksRoutine = StartCoroutine(ExecuteTasksInSeries()); 167 | } 168 | 169 | void Update() 170 | { 171 | if (Input.GetKeyDown(KeyCode.S)) 172 | { 173 | // Stop all coroutines 174 | StopAllCoroutines(); 175 | // Specify the coroutine 176 | StopCoroutine(runTasksRoutine); 177 | } 178 | } 179 | } 180 | ``` 181 |
182 |
183 | Events 184 | 185 | - EventManager.cs 186 | 187 | ```csharp 188 | using UnityEngine; 189 | using System.Collections; 190 | 191 | public class EventManager : MonoBehaviour 192 | { 193 | public delegate void ClickAction(); 194 | public static event ClickAction OnClicked; 195 | 196 | 197 | void OnGUI() 198 | { 199 | if(GUI.Button(new Rect(Screen.width / 2 - 50, 5, 100, 30), "Click")) 200 | { 201 | if(OnClicked != null) 202 | OnClicked(); 203 | } 204 | } 205 | } 206 | ``` 207 | 208 | - TeleportScript.cs 209 | 210 | ```csharp 211 | using UnityEngine; 212 | using System.Collections; 213 | 214 | public class TeleportScript : MonoBehaviour 215 | { 216 | void OnEnable() 217 | { 218 | EventManager.OnClicked += Teleport; 219 | } 220 | 221 | 222 | void OnDisable() 223 | { 224 | EventManager.OnClicked -= Teleport; 225 | } 226 | 227 | 228 | void Teleport() 229 | { 230 | Vector3 pos = transform.position; 231 | pos.y = Random.Range(1.0f, 3.0f); 232 | transform.position = pos; 233 | } 234 | } 235 | ``` 236 | 237 | - TurnColorScript.cs 238 | 239 | ```csharp 240 | using UnityEngine; 241 | using System.Collections; 242 | 243 | public class TurnColorScript : MonoBehaviour 244 | { 245 | void OnEnable() 246 | { 247 | EventManager.OnClicked += TurnColor; 248 | } 249 | 250 | 251 | void OnDisable() 252 | { 253 | EventManager.OnClicked -= TurnColor; 254 | } 255 | 256 | 257 | void TurnColor() 258 | { 259 | Color col = new Color(Random.value, Random.value, Random.value); 260 | renderer.material.color = col; 261 | } 262 | } 263 | ``` 264 |
265 | -------------------------------------------------------------------------------- /CODE_BASICS.md: -------------------------------------------------------------------------------- 1 | # Code Basics 2 | A list of basics topics working with C# in Unity 3 | 4 |
5 | Player Movement 6 | 7 | ```csharp 8 | using UnityEngine; 9 | using System.Collections; 10 | 11 | public class PlayerController : MonoBehaviour { 12 | 13 | public float speed; 14 | 15 | private Rigidbody rb; 16 | 17 | void Start () 18 | { 19 | rb = GetComponent(); 20 | } 21 | 22 | // FixedUpdate is called at a fixed interval and is independent of frame rate. 23 | // Put physics code here. 24 | void FixedUpdate () 25 | { 26 | float moveHorizontal = Input.GetAxis ("Horizontal"); 27 | float moveVertical = Input.GetAxis ("Vertical"); 28 | 29 | Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); 30 | rb.AddForce (movement * speed); 31 | } 32 | } 33 | ``` 34 |
35 |
36 | Moving Camera 37 | 38 | ```csharp 39 | using UnityEngine; 40 | using System.Collections; 41 | 42 | public class CameraController : MonoBehaviour { 43 | 44 | public GameObject player; 45 | 46 | private Vector3 offset; 47 | 48 | void Start () 49 | { 50 | offset = transform.position - player.transform.position; 51 | } 52 | 53 | void LateUpdate () 54 | { 55 | transform.position = player.transform.position + offset; 56 | } 57 | } 58 | ``` 59 |
60 |
61 | Collectable Objects 62 | 63 | ```csharp 64 | using UnityEngine; 65 | using System.Collections; 66 | 67 | public class PlayerController : MonoBehaviour { 68 | 69 | void OnTriggerEnter(Collider other) 70 | { 71 | if (other.gameObject.CompareTag ("Pick Up")) 72 | { 73 | other.gameObject.SetActive (false); 74 | } 75 | } 76 | } 77 | ``` 78 |
79 |
80 | Score Display 81 | 82 | ```csharp 83 | using UnityEngine; 84 | using UnityEngine.UI; 85 | using System.Collections; 86 | 87 | public class PlayerController : MonoBehaviour { 88 | 89 | public Text countText; 90 | public Text winText; 91 | private int count; 92 | 93 | void Start () 94 | { 95 | count = 0; 96 | SetCountText(); 97 | winText.text = ""; 98 | } 99 | 100 | void OnTriggerEnter(Collider other) 101 | { 102 | if (other.gameObject.CompareTag ( "Pick Up")) 103 | { 104 | count = count + 1; 105 | SetCountText (); 106 | } 107 | } 108 | 109 | void SetCountText () 110 | { 111 | countText.text = "Count: " + count.ToString (); 112 | if (count >= 12) 113 | { 114 | winText.text = "You Win!"; 115 | } 116 | } 117 | } 118 | ``` 119 |
120 |
121 | Behaviour Components 122 | 123 | ```csharp 124 | using UnityEngine; 125 | using System.Collections; 126 | 127 | public class ExampleBehaviourScript : MonoBehaviour 128 | { 129 | void Update() 130 | { 131 | if (Input.GetKeyDown(KeyCode.R)) 132 | { 133 | GetComponent ().material.color = Color.red; 134 | } 135 | } 136 | } 137 | ``` 138 |
139 |
140 | Check State 141 | 142 | ```csharp 143 | using UnityEngine; 144 | using System.Collections; 145 | 146 | public class CheckState : MonoBehaviour 147 | { 148 | public GameObject myObject; 149 | 150 | void Start () 151 | { 152 | Debug.Log("Active Self: " + myObject.activeSelf); 153 | Debug.Log("Active in Hierarchy" + myObject.activeInHierarchy); 154 | } 155 | } 156 | ``` 157 |
158 |
159 | Translate and Rotate 160 | 161 | ```csharp 162 | using UnityEngine; 163 | using System.Collections; 164 | 165 | public class TransformFunctions : MonoBehaviour 166 | { 167 | public float moveSpeed = 10f; 168 | public float turnSpeed = 50f; 169 | 170 | // Update is called once per frame 171 | void Update () 172 | { 173 | if(Input.GetKey(KeyCode.UpArrow)) 174 | transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime); 175 | 176 | if(Input.GetKey(KeyCode.DownArrow)) 177 | transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime); 178 | 179 | if(Input.GetKey(KeyCode.LeftArrow)) 180 | transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime); 181 | 182 | if(Input.GetKey(KeyCode.RightArrow)) 183 | transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime); 184 | } 185 | } 186 | ``` 187 |
188 |
189 | Look At 190 | 191 | ```csharp 192 | using UnityEngine; 193 | using System.Collections; 194 | 195 | public class CameraLookAt : MonoBehaviour 196 | { 197 | public Transform target; 198 | 199 | void Update () 200 | { 201 | transform.LookAt(target); 202 | } 203 | } 204 | ``` 205 |
206 |
207 | Linear Interpolation 208 | 209 | ```csharp 210 | // In this case, result = 4 211 | float result = Mathf.Lerp (3f, 5f, 0.5f); 212 | // The Mathf.Lerp function takes 3 float parameters: one representing the value to interpolate from; another representing the value to interpolate to and a final float representing how far to interpolate 213 | 214 | Vector3 from = new Vector3 (1f, 2f, 3f); 215 | Vector3 to = new Vector3 (5f, 6f, 7f); 216 | 217 | // Here result = (4, 5, 6) 218 | Vector3 result = Vector3.Lerp (from, to, 0.75f); 219 | 220 | // The same principle is applied when using Color.Lerp. 221 | // In the Color struct, colours are represented by 4 floats representing red, blue, green and alpha. 222 | // When using Lerp, these floats are interpolated just as with Mathf.Lerp and Vector3.Lerp. 223 | 224 | void Update () 225 | { 226 | light.intensity = Mathf.Lerp(light.intensity, 8f, 0.5f * Time.deltaTime); 227 | // With deltaTime, the change to intensity would happen per second instead of per frame. 228 | } 229 | ``` 230 |
231 |
232 | GetAxis Horizontal and Vertical 233 | 234 | ```csharp 235 | using UnityEngine; 236 | using System.Collections; 237 | 238 | public class DualAxisExample : MonoBehaviour 239 | { 240 | public float range; 241 | public GUIText textOutput; 242 | 243 | void Update () 244 | { 245 | float h = Input.GetAxis("Horizontal"); 246 | float v = Input.GetAxis("Vertical"); 247 | float xPos = h * range; 248 | float yPos = v * range; 249 | 250 | transform.position = new Vector3(xPos, yPos, 0); 251 | textOutput.text = "Horizontal Value Returned: "+h.ToString("F2")+"\nVertical Value Returned: "+v.ToString("F2"); 252 | } 253 | } 254 | ``` 255 |
256 |
257 | OnMouseDown 258 | 259 | ```csharp 260 | using UnityEngine; 261 | using System.Collections; 262 | 263 | public class MouseClick : MonoBehaviour 264 | { 265 | void OnMouseDown () 266 | { 267 | rigidbody.AddForce(-transform.forward * 500f); 268 | rigidbody.useGravity = true; 269 | } 270 | } 271 | ``` 272 |
273 |
274 | Using Other Components 275 | 276 | ```csharp 277 | using UnityEngine; 278 | using System.Collections; 279 | 280 | public class UsingOtherComponents : MonoBehaviour 281 | { 282 | public GameObject otherGameObject; 283 | 284 | private AnotherScript anotherScript; 285 | private YetAnotherScript yetAnotherScript; 286 | private BoxCollider boxCol; 287 | 288 | void Awake () 289 | { 290 | anotherScript = GetComponent(); 291 | yetAnotherScript = otherGameObject.GetComponent(); 292 | boxCol = otherGameObject.GetComponent(); 293 | } 294 | 295 | void Start () 296 | { 297 | boxCol.size = new Vector3(3,3,3); 298 | Debug.Log("The player's score is " + anotherScript.playerScore); 299 | Debug.Log("The player has died " + yetAnotherScript.numberOfPlayerDeaths + " times"); 300 | } 301 | } 302 | ``` 303 |
304 |
305 | Using Delta Times 306 | 307 | ```csharp 308 | using UnityEngine; 309 | using System.Collections; 310 | 311 | public class UsingDeltaTime : MonoBehaviour 312 | { 313 | public float speed = 8f; 314 | public float countdown = 3.0f; 315 | 316 | void Update () 317 | { 318 | countdown -= Time.deltaTime; 319 | if(countdown <= 0.0f) 320 | light.enabled = true; 321 | 322 | if(Input.GetKey(KeyCode.RightArrow)) 323 | transform.position += new Vector3(speed * Time.deltaTime, 0.0f, 0.0f); 324 | } 325 | } 326 | ``` 327 |
328 |
329 | Using Data Types 330 | 331 | ```csharp 332 | using UnityEngine; 333 | using System.Collections; 334 | 335 | public class DatatypeScript : MonoBehaviour 336 | { 337 | void Start () 338 | { 339 | //Value type variable 340 | Vector3 pos = transform.position; 341 | pos = new Vector3(0, 2, 0); 342 | 343 | //Reference type variable 344 | Transform tran = transform; 345 | tran.position = new Vector3(0, 2, 0); 346 | } 347 | } 348 | ``` 349 |
350 |
351 | Using Instantiate 352 | 353 | ```csharp 354 | using UnityEngine; 355 | using System.Collections; 356 | 357 | public class UsingInstantiate : MonoBehaviour 358 | { 359 | public Rigidbody rocketPrefab; 360 | public Transform barrelEnd; 361 | 362 | 363 | void Update () 364 | { 365 | if(Input.GetButtonDown("Fire1")) 366 | { 367 | Rigidbody rocketInstance = Instantiate(rocketPrefab, barrelEnd.position, barrelEnd.rotation) as Rigidbody; 368 | rocketInstance.AddForce(barrelEnd.forward * 5000); 369 | } 370 | } 371 | } 372 | ``` 373 |
374 |
375 | Arrays 376 | 377 | ```csharp 378 | using UnityEngine; 379 | using System.Collections; 380 | 381 | public class Arrays : MonoBehaviour 382 | { 383 | public GameObject[] players; 384 | 385 | void Start () 386 | { 387 | players = GameObject.FindGameObjectsWithTag("Player"); 388 | 389 | for(int i = 0; i < players.Length; i++) 390 | { 391 | Debug.Log("Player Number "+i+" is named "+players[i].name); 392 | } 393 | } 394 | } 395 | ``` 396 |
397 |
398 | Invoke 399 | 400 | ```csharp 401 | using UnityEngine; 402 | using System.Collections; 403 | 404 | public class InvokeScript : MonoBehaviour 405 | { 406 | public GameObject target; 407 | 408 | void Start() 409 | { 410 | Invoke (nameof(SpawnObject), 2); 411 | // Repeating 412 | InvokeRepeating(nameof(SpawnObject), 2, 1); 413 | // TODO: Use UniRx/Observables instead :) 414 | } 415 | 416 | void SpawnObject() 417 | { 418 | float x = Random.Range(-2.0f, 2.0f); 419 | float z = Random.Range(-2.0f, 2.0f); 420 | Instantiate(target, new Vector3(x, 2, z), Quaternion.identity); 421 | } 422 | } 423 | ``` 424 |
425 |
426 | Enumerations 427 | 428 | ```csharp 429 | using UnityEngine; 430 | using System.Collections; 431 | 432 | public class EnumScript : MonoBehaviour 433 | { 434 | enum Direction {North, East, South, West}; 435 | 436 | void Start () 437 | { 438 | Direction myDirection; 439 | 440 | myDirection = Direction.North; 441 | } 442 | 443 | Direction ReverseDirection (Direction dir) 444 | { 445 | if(dir == Direction.North) 446 | dir = Direction.South; 447 | else if(dir == Direction.South) 448 | dir = Direction.North; 449 | else if(dir == Direction.East) 450 | dir = Direction.West; 451 | else if(dir == Direction.West) 452 | dir = Direction.East; 453 | 454 | return dir; 455 | } 456 | } 457 | ``` 458 |
459 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Maintenance 4 | 5 | 6 | Follow @jdnichollsc 7 | 8 |

9 | 10 |

Awesome Unity Games 🎮

11 |

A curated list of awesome Unity Games (Open Source), code examples and resources.

12 |

13 | Unity Games 14 |

15 | Credits to https://codepen.io/boldfacedesign/pen/EoGgD 16 |

17 |

18 | 19 | ## Adventure 20 | - [San Andreas Unity](https://github.com/GTA-ASM/SanAndreasUnity) - An open source reimplementation of GTA San Andreas game engine in Unity. 21 | 22 | ## Puzzle 23 | - [Nodulus](https://github.com/Hyperparticle/nodulus) - A puzzle game with a clever twist. Based on the mathematical theory behind plank puzzles, consists of a grid of cubes and rods which can be rotated with a swipe. 24 | - [Angry Birds style game](https://github.com/dgkanatsios/AngryBirdsStyleGame) - An effort to replicate a level and relevant mechanisms of Rovio's famous Angry Birds game, built in Unity game engine. Source code is provided for educational purposes. 25 | - [Match-3 game](https://github.com/dgkanatsios/MatchThreeGame) - A match-3 game in Unity (like Candy Crush and Bejeweled). 26 | 27 | ## Role 28 | - [Darkest Dungeon](https://github.com/Reinisch/Darkest-Dungeon-Unity) - Darkest Dungeon port in Unity. Almost completely identical to the original. 29 | 30 | ## RPG 31 | - [Hogwarts](https://github.com/OpenHogwarts/hogwarts) - A Hogwarts (Harry Potter) open sandbox game made in Unity. 32 | 33 | ## Runner 34 | - [InfiniteRunner3D](https://github.com/dgkanatsios/InfiniteRunner3D) - Creating an infinite 3D runner game in Unity. 35 | 36 | ## Sandbox 37 | - [CubeWorld](https://github.com/federicodangelo/CubeWorld) - Minecraft like game made in Unity. 38 | 39 | ## Shooter 40 | - [Multiplayer-FPS](https://github.com/Armour/Multiplayer-FPS) - A multiplayer first-person shooter game based on Unity3D. Different types of input devices are supported, including Kinect, Xbox controllers, Leap motion, and VR Glasses. 41 | 42 | ## Strategy 43 | - [Starcraft Unity3D](https://github.com/coconauts/startcraft-unity3d) - A recreation of the classic Starcraft game by Blizzard, on Unity3D. 44 | 45 | --- 46 | 47 |

48 | Awesome Resources 49 |

50 | 51 | ## Code Examples 52 | - [Basics](./CODE_BASICS.md) 53 | - [Intermediate](./CODE_INTERMEDIATE.md) 54 | 55 | ## Augmented reality 56 | - [ARCore](https://developers.google.com/ar/develop/unity) - Build new augmented reality experiences that seamlessly blend the digital and physical worlds. Transform the way people play, shop, learn, create, and experience the world together—at Google scale. 57 | - [ARKit](https://developer.apple.com/augmented-reality) - Build unparalleled augmented reality experiences for hundreds of millions of users on iOS and iPadOS, the biggest AR platforms in the world. 58 | - [Vuforia](https://engine.vuforia.com/engine) - The World’s Most Widely Deployed AR. 59 | 60 | ## Virtual Reality 61 | 62 | - [Innoactive Creator](https://github.com/Innoactive/Creator) - Scalable and maintainable Unity-based VR training. 63 | - [Innoactive Creator Examples](https://github.com/Innoactive/Creator-Examples) - Simple examples showcasing the capabilities of the Innoactive Creator. 64 | - [XR-Interaction-Toolkit-Examples](https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples) - Various examples to use with the XR Interaction Toolkit. 65 | - [OpenVR XR](https://github.com/ValveSoftware/unity-xr-plugin) - OpenVR plugin for Unity's XR API. 66 | 67 | 68 | ## Controllers 69 | - [2D-Platformer-Hunter](https://github.com/ta-david-yu/2D-Platformer-Hunter) - A 2D Platformer Controller in Unity. 70 | 71 | ## Editor 72 | - [Runtime Unity Editor/Debugging Tools](https://github.com/ManlyMarco/RuntimeUnityEditor) - In-game inspector and debugging tools for applications made with Unity3D game engine. 73 | - [Path-Creator](https://github.com/SebLague/Path-Creator) - An intuitive and lightweight editor for quickly creating smooth paths in the editor. 74 | - [UIWidgets](https://github.com/Unity-Technologies/com.unity.uiwidgets) - A Unity Package which helps developers to create, debug and deploy efficient, cross-platform Apps. 75 | 76 | ## Scripting 77 | - [ScriptableObject-Architecture](https://github.com/DanielEverland/ScriptableObject-Architecture) - Makes using Scriptable Objects as a fundamental part of your architecture in Unity super easy. 78 | - [UniRx](https://github.com/neuecc/UniRx) - Reactive Extensions for Unity. 79 | - [C-Sharp-Promise](https://github.com/Real-Serious-Games/C-Sharp-Promise) - Promises library for C# for management of asynchronous operations. 80 | - [FSM_Command_Patterns](https://github.com/hansschaa/FSM_Command_Patterns) - A basic platform game developed for help to undertanding State pattern and Command pattern. 81 | 82 | ## Networking 83 | - [RestClient](https://github.com/proyecto26/RestClient) - 🦄 Simple HTTP and REST client for Unity based on Promises, also supports Callbacks! 🎮. 84 | 85 | ## Platforms 86 | - [Native Toolkit](https://github.com/ryanw3bb/unity-native-toolkit) - Easily integrate native iOS & Android functionality into Unity projects. 87 | 88 | ## Utilities 89 | - [Yarn Spinner](https://github.com/YarnSpinnerTool/YarnSpinner) - A tool for building interactive dialogue in games! 90 | - [Unity2D Components](https://github.com/cmilr/Unity2D-Components) - A varied collection of Unity3D components that I've built for use in the 2D Platformer/RPG I'm currently developing. 91 | - [Unity Image Cropper](https://github.com/yasirkula/UnityImageCropper) - A uGUI based image cropping solution for Unity 3D. 92 | - [ChainSafe Gaming](https://github.com/ChainSafe/web3.unity) - Unity SDK for building games that interact with blockchains. 93 | 94 | ## Guides 95 | - [Coding in C# in Unity for beginners](https://unity3d.com/learning-c-sharp-in-unity-for-beginners) - The very basics of coding, like variables, functions and classes, and how to use them. 96 | - [Design Patterns Written in Unity3D](https://github.com/QianMo/Unity-Design-Pattern) - All Gang of Four Design Patterns written in Unity C# with many examples. 97 | 98 | ## Tutorials 99 | - [Introduction to Roll-a-Ball](https://youtu.be/RFlh8pTf4DU) - An introduction to the Roll-a-ball project, showing the final game and describing what will be covered in this tutorials. 100 | - [Setting up the Game](https://youtu.be/W_fAidYRGzs) - Creating a new project and setting up the basic game. 101 | - [Moving the Player](https://youtu.be/7C7WWxUxPZE) - Moving the player object using player input and physics forces. 102 | - [Moving the Camera](https://youtu.be/Xcm5H2J95iI) - Moving the camera relative to the player. 103 | - [Setting up the Play Area](https://youtu.be/dahT0wRVO1Q) - Setting up the play area. 104 | - [Creating Collectable Objects](https://youtu.be/HlDGSStxuHI) - Creating and placing the "Pick Up" collectables. 105 | - [Collecting the Pick Up Objects](https://youtu.be/XtR29MmzuT0) - Collecting the pick-up objects; discussing physics, collisions and triggers. 106 | - [Displaying the Score and Text](https://youtu.be/bFSLI2cmYYo) - Counting, displaying text and ending the game. 107 | - [Building the Game](https://youtu.be/hSg3e1M3hKY) - Building the game as a Standalone application. 108 | - [Scripts as Behaviour Components](https://youtu.be/Z0Z7xc18CcA) - Learn about the behaviour component that is a Unity script, and how to Create and Attach them to objects. 109 | - [Variables And Functions](https://youtu.be/-c1RsydH2nA) - What are Variables and Functions, and how do they store and process information for us? 110 | - [Conventions and Syntax](https://youtu.be/0mks0QaWCNQ) - Learn about some basic conventions and syntax of writing code. 111 | - [If Statements](https://youtu.be/PQihrWCOSic) - How to use IF statements to set conditions in your code. 112 | - [Loops](https://youtu.be/Jefkb3Gm7vE) - How to use the For, While and Do-While Loops as well as the For Each loop to repeat actions in code. 113 | - [Scope and Access Modifiers](https://youtu.be/_0oBLCJcpCs) - Understanding variable & function scope and accessibility. 114 | - [Awake and Start](https://youtu.be/4QdjoV63wjM) - How to use Awake and Start, two of Unity's initialisation functions. 115 | - [Update and FixedUpdate](https://youtu.be/u42aWzAIAqg) - How to effect changes every frame with the Update and FixedUpdate functions, and their differences. 116 | - [Vector Maths](https://youtu.be/e3z91RqZPAk) - A primer on Vector maths - as well as information on the Dot and Cross products. 117 | - [Enabling and Disabling Components](https://youtu.be/PCdg3cnQfZ4) - How to enable and disable components via script during runtime. 118 | - [Activating GameObjects](https://youtu.be/MhPFB-rAdlg) - Learn about the behaviour component that is a Unity script, and how to Create and Attach them to objects. 119 | - [Translate and Rotate](https://youtu.be/32JkMANaMpk) - How to use the two transform functions Translate and Rotate to effect a non-rigidbody object's position and rotation. 120 | - [LookAt](https://youtu.be/cAAqf5J7_9w) - How to make a game object's transform face another's by using the LookAt function. 121 | - [Destroy](https://youtu.be/pRDj3jss5t8) - How to use the **Destroy** function to remove GameObjects and Components at runtime. 122 | - [GetButton and GetKey](https://youtu.be/-A7D5Rcumz4) - How to get button or key for input and how these axes behave / can be modified with the Input manager. 123 | - [GetAxis](https://youtu.be/MK4OmsViqMA) - How to "get axis" based input for your games in Unity and how these axes can be modified with the Input manager. 124 | - [OnMouseDown](https://youtu.be/c69oZprM1oc) - How to detect mouse clicks on a Collider or GUI element. 125 | - [GetComponent](https://youtu.be/xbDKC4zP9XY) - How to use the GetComponent function to address properties of other scripts or components. 126 | - [DeltaTime](https://youtu.be/Gcoj3llfzSw) - What is Delta Time and how can it be used in your games to smooth and interpret values. 127 | - [DataTypes](https://youtu.be/IVcx-tSxjys) - Learn the important differences between Value and Reference data types, in order to better understand how variables work. 128 | - [Classes](https://youtu.be/odKtPBsyFnw) - How to use Classes to store and organise your information, and how to create constructors to work with parts of your class. 129 | - [Instantiate](https://youtu.be/Q3u0x8VRJS4) - How to use Instantiate to create clones of a Prefab during runtime. 130 | - [Arrays](https://youtu.be/Zn4BDIXhy-M) - Using arrays to collect variables together into a more manageable form. 131 | - [Invoke](https://youtu.be/-YgM4DXGeq4) - The Invoke functions allow you to schedule method calls to occur at a later time. 132 | - [Enumerations](https://youtu.be/L2E2aB1CMYw) - Enumerations allow you to create a collection of related constants. 133 | - [Switch Statements](https://youtu.be/-PWvI3q6_OE) - Switch statements act like streamline conditionals. They are useful for when you want to compare a single variable against a series of constants. 134 | - [Events](https://youtu.be/k4JlFxPcqlg) - Learn how to use special delegates called Events in order to subscribe methods (functions) to create flexible broadcast systems in your code. 135 | - [Creating a Text Based Adventure Part 1](https://youtu.be/jAf1I1UWo5Q) - Learn how to program a text based adventure game in which the player explores a series of rooms by reading text and inputting commands via the keyboard. 136 | - [Creating a Text Based Adventure Part 2](https://youtu.be/Bak8azAM_cA) - Learn how to to display the descriptions of all the items in a room when we enter it. 137 | - [How to Play Test Game Mods (Official Unity Tutorial)](https://youtu.be/kZCJmKVQAPQ) - In the Play Testing In-Editor Tutorial, you will learn how to play and mod your Microgame in Unity. 138 | 139 | ## Tools 140 | - [OpenUPM](https://openupm.com) - Open Source Unity Package Registry. 141 | 142 | ## YouTube Channels 143 | - [Brackeys](https://www.youtube.com/user/Brackeys/videos) - Game Dev Tutorials 144 | 145 | ## Architecture 146 | - [SOLID](https://github.com/ugonnathelma/articles/blob/master/the-solid-principles-in-pictures/the-solid-principles-in-pictures.md) - The S.O.L.I.D Principles in Pictures. 147 | - [.Net Documentation](https://github.com/proyecto26/dotnet-documentation) - SOLID, DI, N-Tier, Logs, etc with dotnet. 148 | 149 | ## Other Awesome Lists 150 | - [GameDev-Resources](https://github.com/Kavex/GameDev-Resources) - A wonderful list of Game Development resources. 151 | - [awesome-unity3d](https://github.com/insthync/awesome-unity3d) - A categorized collection of awesome opensource unity3d repos. 152 | - [Awesome Unity Open Source on GitHub (800+)](https://github.com/baba-s/awesome-unity-open-source-on-github) - A categorized collection of awesome Unity open source on GitHub. 153 | - [Awesome Unity FREE](https://github.com/netpyoung/awesome-unity-free) - A community driven list of useful Unity Game Engine "FREE" packages, libraries and others. 154 | - [Awesome Unity Community](https://github.com/UnityCommunity/AwesomeUnityCommunity) - A categorized community-driven collection of high-quality awesome Unity assets, projects, and resources. 155 | 156 | ## Concepts 157 | * **3DOF:** A term often used in the context of virtual reality, refers to tracking of rotational motion only: pitch, yaw, and roll. 158 | * **6DOF:** Refers to the freedom of movement of a rigid body in three-dimensional space. 159 | 160 | ## Supporting 🍻 161 | I believe in Unicorns 🦄 162 | Support [me](http://www.paypal.me/jdnichollsc/2), if you do too. 163 | 164 | Donate **Ethereum**, **ADA**, **BNB**, **SHIBA**, **USDT/USDC**, **DOGE**, etc: 165 | 166 | > Wallet address: jdnichollsc.eth 167 | 168 | Please let us know your contributions! 🙏 169 | 170 | ## Happy coding 💯 171 | Made with ❤️ 172 | 173 | 174 | https://avatars0.githubusercontent.com/u/28855608?s=200&v=4" align="right"> 175 | --------------------------------------------------------------------------------