The Debug.Log shows: GotSelectionBox:UnityEngine.Transform
the GetCurrentGameObject returns a selected GameObject. If I just use the commented line it works, but then I am getting to many Materials, I just want the materials in SelectedGameObject/Container/ContainerBox/ElementBox. ElementBox is an Empty GameObject, which can contain a further GameObject with Materials, that I am trying to get and change. I am checking if there is an ElementBox there, so no errors occur, but it is returning as if it were null even though there is an object there. Is this because it is an empty GameObject?. I get all materials if I just use the currentObject, which is not exactly what I want, but it works. The current GameObject is a loaded prefab and also an empty GameObject, containing multiple other GameObjects.
UPDATE: I tried this and it works ok:
I highly recommend against using
Instead try putting a script on your game object returned by
answered Jul 13 '10 at 08:09 AM