O'Reilly logo

Unity 5 for Android Essentials by Valera Cogut

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unity C# and Unity JS optimization tips and tricks

To begin, we will consider some aspects of optimization concerning the JavaScript programming language. Try to avoid the use of dynamic typing in JavaScript. The best solution for your performance is undoubtedly static typing. The use of dynamic typing of variables will be consumed while executing a code to find the appropriate data type for a particular variable, which in principle could and should be avoided by specifying the data types for all your variables. Bad and good examples are shown here:

// Dynamic Typing, BAD FOR YOUR PERFORMANCE
var yourVariableName = 23;

// Static Typing, GOOD FOR YOUR PERFORMANCE
var myGo : GameObject = null;

The following example shows what you should not do if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required