I have made an effort to read the scripting tutorials and guides already posted.
I’m just going to recap what I’ve learned and include some basic questions I’ve not yet found an answer to.
I understand:
- The GameObject and script hierarchy, and how to cross access them at runtime (somewhat).
- That regardless of what language we code in, the final result is the CIL byte code.
- C# Boo are more Explicit, JS is more Implicit, it comes down to preference.
I’ve become extremely familiar with JS for the web over the years so I just want to know where the line is drawn with Unity’s JS since it is superficial in comparison.
Is CIL ECMAScript based? Since function overloading is available, it leads me to think no, which raises other questions… Which of these is still possible? (I know some are easy to test for, but others can read this too)
-
In JS for the web I’ve become very used to dynamic arrays and non-permanently-typecast variables.
-
In cases where we know the definitive size for the array, is a faster array class available?
-
does type casting variables with <: Type> offer any run time performance benefits or is it just for development and compile benefits? (I noticed UnityJS will auto type cast variables when initialized with a value)
-
I find it handy to put relevant variables inside a function as if it’s a container (since functions are derived from the object class, this was possible with web JS).
Example
function myFunc() { *code* }
myFunc.myVar = "relevant variable to this function";
- JS has two ways to declare a function, are both accepted?
Example
function myFunc(){ *code* }
// or
var myFunc = function() { *code* };
- Is it possible to re-declare custom functions at arbitrary points in the code?
Example
function myFunc(){ Debug.Log("version 1"); }
// later
myFunc = function(){ Debug.Log(version 2"); };
And finally, when using DontDestroyOnLoad where will that object appear in the new scene? How can we get a handle to it?
Thanks in advance.