A problem people new to Unity and scrpting may run in:
I have a variable.
I know it will be only assigned to a single GameObject or Component for the whole time,
I also know that dynamic/inference typing is much slower than static typing (even if the variable is assigned right away in function Awake and then never changes), so I want to avoid it.
What I don't know is:
Is there a way to find out (with a Debug.Log or something) of what type my dynamically typed variable currently is? (So that I can then assign that type statically)
Thanks & Greetz, Ky.
asked Jan 29 '10 at 01:02 AM
answered Jan 29 '10 at 01:17 AM
The documentation for each function indicates the return type. For example, you mentioned GameObject.Find(), which has this prototype in the docs:
i.e. it returns a GameObject, so
Note that if you're using the built in code editor, highlighting a function name and hitting F1 will load the docs in your browser.
I hope that helps.
answered Jan 29 '10 at 04:21 AM
Assuming the variable is a reference type (not a direct value like "5" or "blah"), you don't even need GetType():
answered Jan 29 '10 at 05:46 AM