Skip to content

Instantly share code, notes, and snippets.

@crcdng
Last active August 2, 2020 21:05
Show Gist options
  • Select an option

  • Save crcdng/008b7a13da030a42bccb69755565d206 to your computer and use it in GitHub Desktop.

Select an option

Save crcdng/008b7a13da030a42bccb69755565d206 to your computer and use it in GitHub Desktop.
A few learnings from working with Unity3D https://unity.com/ (regularly updated)
### 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment