Last active
August 2, 2020 21:05
-
-
Save crcdng/008b7a13da030a42bccb69755565d206 to your computer and use it in GitHub Desktop.
Revisions
-
crcdng revised this gist
Aug 2, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,7 +88,7 @@ To make it work, set: Unity's built in audio system is quite flexible and powerful. If your audio sources are files or mod trackers you might not need even need addiitional audio midleware. Instead of attaching audio processing components to GameObjects, you can manage your game audio from a central mixing desk. This setup features Audio Mixers, Audio Groups of filters and effects, Snapshots to remember and transition between parameter setups, Views to toggle the visibilty of elements, Sends and Receives for audio sidechains and parameters that ca be exposed to scripts. You can even write your own DSP effects and add them to the stack (Native Audio Plugin SDK). Surprisingly however, Unity (currently) does not allow to copy or move Audio Groups between Mixers (confirmed for 2019 LTS: https://twitter.com/unity3d/status/1285162528226582528). Say, you started out with one central Audio Mixer but later decided that you want to have one Mixer per Scene. You cannot move your existing Audio Groups to other Mixers and therefore you would have to start from scratch 🙀. -
crcdng revised this gist
Aug 2, 2020 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -86,15 +86,18 @@ To make it work, set: #### 4. Organize your Audio Mixer setup beforehand. Unity's built in audio system is quite flexible and powerful. If your audio sources are files or mod trackers you might not need even need addiitional audio midleware. Instead of attaching audio processing components to GameObjects, you can manage your game audio from a central mixing desk. This setup features Audio Mixers, Audio Groups of filters and effects, Snapshots to remember and transition between parameter setups, Views to toggle the visibilty of elements, Sends and Receives for audio sidechains and parameters that ca be exposed to scripts. You can even write your own DSP effects and add them to the stack. Surprisingly however, Unity (currently) does not allow to copy or move Audio Groups between Mixers (confirmed for 2019 LTS: https://twitter.com/unity3d/status/1285162528226582528). Say, you started out with one central Audio Mixer but later decided that you want to have one Mixer per Scene. You cannot move your existing Audio Groups to other Mixers and therefore you would have to start from scratch 🙀. **TL;DR** If you use Unity's built in audio system, plan your Audio Mixer setup carefully beforehand. More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html https://gamedevbeginner.com/10-unity-audio-tips-that-you-wont-find-in-the-tutorials/ https://www.gamasutra.com/blogs/ZanderHulme/20190107/333794/Unity_Audio_Import_Optimisation__getting_more_BAM_for_your_RAM.php #### 5. Consider organizing your architecture around Scriptable Objects instead of MonoBehaviours. -
crcdng revised this gist
Jul 29, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -96,7 +96,7 @@ More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html https://gamedevbeginner.com/10-unity-audio-tips-that-you-wont-find-in-the-tutorials/ #### 5. Consider organizing your architecture around Scriptable Objects instead of MonoBehaviours. In particular beginners learn a development philosophy in Unity that revolves around attaching scripts to GameObjects. In order to communicate with other components, these script have address components and other GameObjects through attributes and method calls such as `.gameObject`, `GetComponent<ComponentType>()`and variants thereof. This is plausible for a small number of objects in a game scene. With growing complexity these constructions get less and less manageable. -
crcdng revised this gist
Jul 28, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -97,6 +97,9 @@ https://docs.unity3d.com/Manual/Audio.html https://gamedevbeginner.com/10-unity-audio-tips-that-you-wont-find-in-the-tutorials/ #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours. In particular beginners learn a development philosophy in Unity that revolves around attaching scripts to GameObjects. In order to communicate with other components, these script have address components and other GameObjects through attributes and method calls such as `.gameObject`, `GetComponent<ComponentType>()`and variants thereof. This is plausible for a small number of objects in a game scene. With growing complexity these constructions get less and less manageable. (tbd.) #### 6. Start learning Unity ECS, not MonoBehaviours. -
crcdng revised this gist
Jul 27, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,7 @@ Always create a new object instance in `Start()` and update its attributes in `U If you need a variable amount of objects that are spawned depending on some event that happens during the game then use an object pool. An object pool is based the same principle: create the objects in advance and re-use them in the game loop. Note: While the Unity compiler might be able to optimise away the object creation in the particular case above, imagine what happens when you instatiate complex objects that have multiple components and assets and instatiate other objects in turn. Therefore I like to think of avoiding object creation in the game loop as a habit to practice. **TL;DR** You should never see the `new` keyword inside `Update()`. Your garbage collector will thank you. -
crcdng revised this gist
Jul 27, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -104,7 +104,7 @@ https://gamedevbeginner.com/10-unity-audio-tips-that-you-wont-find-in-the-tutori #### 7. Selected resources: https://docs.unity3d.com/Manual/index.html https://docs.unity3d.com/ScriptReference/index.html https://docs.microsoft.com/en-us/dotnet/csharp/ https://jacksondunstan.com/ -
crcdng revised this gist
Jul 27, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -92,9 +92,9 @@ Surprisingly, Unity (currently) does not allow to copy or move Audio Groups betw **TL;DR** If you use Unity's built in audio system, plan your Audio Mixer setup carefully beforehand. More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html https://gamedevbeginner.com/10-unity-audio-tips-that-you-wont-find-in-the-tutorials/ #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours. (tbd.) -
crcdng revised this gist
Jul 27, 2020 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -92,7 +92,9 @@ Surprisingly, Unity (currently) does not allow to copy or move Audio Groups betw **TL;DR** If you use Unity's built in audio system, plan your Audio Mixer setup carefully beforehand. More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html https://gamedevbeginner.com/10-unity-audio-tips-that-you-wont-find-in-the-tutorials/ #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours. (tbd.) -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -97,10 +97,6 @@ More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.htm #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours. (tbd.) #### 6. Start learning Unity ECS, not MonoBehaviours. (tbd.) -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,6 +55,8 @@ Always create a new object instance in `Start()` and update its attributes in `U If you need a variable amount of objects that are spawned depending on some event that happens during the game then use an object pool. An object pool is based the same principle: create the objects in advance and re-use them in the game loop. Note: While the Unity compiler might be able to optimise away the object creation in the particular case above, imagine that you instatiate complex objects which consist of multiple components, assets and other resources and in turn instatiate other objects. Therefore I like to think of avoiding object creation in the game loop as a habit. **TL;DR** You should never see the `new` keyword inside `Update()`. Your garbage collector will thank you. More information about object pools in Unity: @@ -95,6 +97,10 @@ More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.htm #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours. (tbd.) cat.GetComponent<ScoreKeeper>() playBtn.gameObject.SetActive(true); #### 6. Start learning Unity ECS, not MonoBehaviours. (tbd.) -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -93,10 +93,10 @@ Surprisingly, Unity (currently) does not allow to copy or move Audio Groups betw More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours. (tbd.) #### 6. Start learning Unity ECS, not MonoBehaviours. (tbd.) #### 7. Selected resources: -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; public class Correct : MonoBehaviour { Vector3 movement; @@ -53,8 +53,7 @@ public class Wrong : MonoBehaviour Always create a new object instance in `Start()` and update its attributes in `Update()`. If you need a variable amount of objects that are spawned depending on some event that happens during the game then use an object pool. An object pool is based the same principle: create the objects in advance and re-use them in the game loop. **TL;DR** You should never see the `new` keyword inside `Update()`. Your garbage collector will thank you. -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 41 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,13 +7,48 @@ Unfortunately one of the first things you see in many Unity game tutorials is a Wrong: ``` using System.Collections; using System.Collections.Generic; using UnityEngine; public class Wrong : MonoBehaviour { void Start() { } void Update() { // x, y are set somewhere else Vector3 movement = new Vector3(x, 0, y); } } ``` Correct: ``` using System.Collections; using System.Collections.Generic; using UnityEngine; public class Wrong : MonoBehaviour { Vector3 movement; void Start() { movement = new Vector3(0, 0, 0); } void Update() { // x, y are set somewhere else movement.x = x; movement.y = y; } } ``` Always create a new object instance in `Start()` and update its attributes in `Update()`. @@ -40,15 +75,15 @@ Note: In other object-oriented programming languages, "attribute" means the same Starting point to learn about attributes in Unity3D: https://docs.unity3d.com/Manual/Attributes.html #### 3. Make the GitHub plugin work. GitHub for Unity is a plugin available on the Unity Asset Store that simplifies working with Git, Github and Git Large File Storage: https://assetstore.unity.com/packages/tools/version-control/github-for-unity-118069. To make it work, set: *Edit > Project Settings > Editor > Version Control > Mode > Visible Meta Files* #### 4. Organize your Audio Mixer setup beforehand. Unity's built in audio system is quite flexible. Instead of attaching audio processing components to GameObjects, you can manage your game audio from a central mixing desk. It works with Audio Mixers, Groups of filters and effects, Snapshots to remember parameter setups, Views to toggle visibilty of stacks and Exposed Parameters to wire up your scripts. @@ -58,13 +93,13 @@ Surprisingly, Unity (currently) does not allow to copy or move Audio Groups betw More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours. #### 6. Start learning Unity ECS, not MonoBehaviours. #### 7. Selected resources: https://docs.unity3d.com/Manual/index.html https://docs.unity3d.com/ScriptReference/index.html -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 31 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,62 +1,72 @@ ### Unity3D tips #### 1. Avoid creating objects inside the game loop. Unfortunately one of the first things you see in many Unity game tutorials is a mistake. Wrong: ``` ``` Correct: ``` ``` Always create a new object instance in `Start()` and update its attributes in `Update()`. If you need a variable amount of objects that are spawned on some event during the game use an object pool. This is based the same principle: creating the objects in advance and re-using them in tha game loop. **TL;DR** You should never see the `new` keyword inside `Update()`. Your garbage collector will thank you. More information about object pools in Unity: https://learn.unity.com/project/c-survival-guide-object-pools?uv=2018.4&courseId=5cf06bd1edbc2a58d7fc3209 #### 2. Use the [HideInInspector] attribute to hide public properties. If you declare a property `public` in order to access it from another script, it will automatically show up in the Inspector. To prevent that, use the `[HideInInspector]` attribute: ``` [HideInInspector] public float life; ``` Note: In other object-oriented programming languages, "attribute" means the same as "property". In C#/Unity it denotes a code annotation in square brackets. Starting point to learn about attributes in Unity3D: https://docs.unity3d.com/Manual/Attributes.html #### 3. Make the GitHub plugin work GitHub for Unity is a plugin available on the Unity Asset Store that simplifies working with Git, Github and Git Large File Storage: https://assetstore.unity.com/packages/tools/version-control/github-for-unity-118069. To make it work, set: *Edit > Project Settings > Editor > Version Control > Mode > Visible Meta Files* #### 4. Organize your Audio Mixer setup beforehand Unity's built in audio system is quite flexible. Instead of attaching audio processing components to GameObjects, you can manage your game audio from a central mixing desk. It works with Audio Mixers, Groups of filters and effects, Snapshots to remember parameter setups, Views to toggle visibilty of stacks and Exposed Parameters to wire up your scripts. Surprisingly, Unity (currently) does not allow to copy or move Audio Groups between Mixers (confirmed for 2019 LTS: https://twitter.com/unity3d/status/1285162528226582528). Say, you started out with one central Audio Mixer but later decided that you want to have one Mixer per Scene. You cannot move your existing Audio Groups to other Mixers and therefore you would have to start from scratch 🙀. **TL;DR** If you use Unity's built in audio system, plan your Audio Mixer setup carefully beforehand. More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html #### 5. Consider organiyzing your architecture around Scriptable Objects instead of MonoBehaviours #### 6. Start learning Unity with ECS, not with MonoBehaviours #### 7. Selected resources https://docs.unity3d.com/Manual/index.html https://docs.unity3d.com/ScriptReference/index.html https://docs.microsoft.com/en-us/dotnet/csharp/ https://jacksondunstan.com/ -
crcdng renamed this gist
Jul 26, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ is the same principle. You create the objects in advance https://learn.unity.com/project/c-survival-guide-object-pools?uv=2018.4&courseId=5cf06bd1edbc2a58d7fc3209 **TL;DR**: You should never see the `new` keyword inside `Update()`. Your garbage collector will thank you. #### 2. Use [HideInInspector] to hide public properties. -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ is the same principle. You create the objects in advance https://learn.unity.com/project/c-survival-guide-object-pools?uv=2018.4&courseId=5cf06bd1edbc2a58d7fc3209 **TL;DR: You should never see the `new` keyword inside `Update()`. Your garbage collector will thank you.** #### 2. Use [HideInInspector] to hide public properties. @@ -52,10 +52,11 @@ Edit > Project Settings > Editor > Version Control > Mode > Visible Meta Files #### 4. Organize your Audio Mixer setup beforehand Unity's built in audio system is quite flexible system, allowing Filters and Effects Audio Groups Surprisingly, you cannot move Audio Groups between Audio Mixers for each Scene. Say, you started out with one Audio Mixer but later decide you want to have one Mixer per Scene. You cannot move your existing Audio Groups and therefore you would have to start from scratch (confirmed here: https://twitter.com/unity3d/status/1285162528226582528). More information about audio in Unity: https://docs.unity3d.com/Manual/Audio.html **TL;DR: If you use Unity's built in audio system, plan your Audio Mixer setup carefully beforehand.** -
crcdng revised this gist
Jul 26, 2020 . 1 changed file with 56 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,61 @@ ### Unity3D tips #### 1. Avoid creating instances in the game loop. Unfortunately one of the first things you see in many Unity game tutorials is a mistake. Wrong: Correct: Always create new Object Create new instances in `Start()` instead and update its attributes in `Update()`. If you need a variable amount of objects created on some agame event use an object pool. This is the same principle. You create the objects in advance https://learn.unity.com/project/c-survival-guide-object-pools?uv=2018.4&courseId=5cf06bd1edbc2a58d7fc3209 You should never see the `new` keyword inside `Update()`. Your garbage collector will thank you. #### 2. Use [HideInInspector] to hide public properties. If a property declaration to prevent the Inspector from showing the property, even if it is public. C# contains attribute names within square brackets, like so: ``` ``` Caveat: In other programming languages, "attribute" usually means the same as "property". In C# it is the annotation in square brackets. Starting point to learn about attributes in Unity3D: https://docs.unity3d.com/Manual/Attributes.html #### 3. Make the GitHub plugin work GitHub for Unity is a plugin available on the Unity Asset Store that simplifies working with Git, Github and Git Large File Storage: https://assetstore.unity.com/packages/tools/version-control/github-for-unity-118069. To make it work, set: Edit > Project Settings > Editor > Version Control > Mode > Visible Meta Files #### 4. Organize your Audio Mixer setup beforehand Unity's built in audio system is a flexible Surprisingly, you cannot rearrange. -
crcdng created this gist
Jul 26, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ ### Unity3D tips Avoid creating instances in the game loop. Unfortunately one of the first things you learn in many Unity game tutorials is a mistake. new Object Create the instances in `Start()` and update its attributes in `Update()` our garbage collector will thank you.