+ 5

Unity Game Development scripting tips

What tips do you have Unity scripting please put in language used

5th Dec 2018, 5:39 PM
Awesome
Awesome - avatar
6 Respostas
+ 4
a nice tip i used was to properly use the private and public keywords, so you dont have lots of GameObjects in your editor, and also, know your GameObjects!
5th Dec 2018, 5:43 PM
Bebida Roja
Bebida Roja - avatar
+ 3
put in the code language
6th Dec 2018, 1:01 PM
Awesome
Awesome - avatar
+ 3
thanks
6th Dec 2018, 1:02 PM
Awesome
Awesome - avatar
+ 2
c#
6th Dec 2018, 1:01 PM
Bebida Roja
Bebida Roja - avatar
+ 2
(some tips can be applied anywhere) * As Bedida mentions, keep everything private unless you must not. If you want to open a variable to the inspector instead of making it public you can use: [SerializeField] note* In c# members are private by default (So you don't need to write private). * Always use meaningful variable names. * Follow some capitalization standards For example, int score; float xPos, yPos; const float MAX_SIZE = 15.3; * Make proper usage of methods -> If a task does something else specifically, turn it into a method and call the method instead of clogging all code in one method. * Do not put to much code in the Update method unless you have to. This runs every frame so can slow down your program if placed on many objects. * Take into account 'design by contract' -> assure errors are handled. Check out: https://docs.unity3d.com/ScriptReference/Assertions.Assert.html * Avoid using: GameObject.find ("objName"); It's slow. Only use it if you must. Cache the result if used many times.
20th Dec 2018, 6:27 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
Object pooling is a very useful concept for making games in Unity, a quick search on YouTube has some good tutorials. I code c# in unity
13th Dec 2018, 8:39 PM
Dan Blaine
Dan Blaine - avatar