Hi all.
I’m new to Unity, so ask for your patience
I encountered that all references to GameObject objects in examples here and in manual stores in Transform typed variables. It confuses me a little but I considered it as the RULE. At least I can use GetComponent() function to access some other component of an game object, can I? I can’t. I can’t access member variable of such object such as layer.
For clarity
var pPC : Transform;
pPC.layer = 1; // BCE0019: 'layer' is not a member of 'UnityEngine.Transform'
(GameObject)pPC.layer = 1; // UCE0001: ';' expected. Insert semicolon at the end
((GameObject)pPC).layer = 1; // BCE0044: expecting ), found 'pPC'
Explain to me, plain one, how can I overcome this misconception.
The thing is that Eric on the one hand GameObject variable seems more convinient to me, but on the other hand Inspector doesn’t display public global variables of this type and consequently doesn’t allow drag’n’drop objects from Hierarchy to such field
You are incorrect. The inspector does display public member variable GameObjects and you can drag and drop objects from the Hierarchy on to such field.
It’s incredible but you right… Only yesterday I have been almost out with tryings to make the GUI show me such variable - in vain. Today - one simple string and all is correct… it seems to me that I have got less problems with MFC then with Unity learning…