Hi, im using a Hashtable for storing new made objects and what groups they belong to. I have created a transform Object called 'Scene' before hand, which also belongs in the Hashtable. The 'Scene' is the main group, later sets will be added to the 'Scene' dynamically.
(dont think to much about the functions, Im still testing things ;) )
Debug.Log("found:"+elemData["Transform"]); //contList.add(parentObject); <-- the later statement works with var parentObject : Transform; //contList.add(elemData["Transform"]); <-- the later statement doenst work contList.add(elemData);// <-- the later statement doenst work }
the add function exists as add(hashtable) and add(transform), the add(transform) just calls the add(hashtable) variation.
After this I add the Objects to the game (at the moment just by pressing fire, later over user clicks and a database)
Debug.Log(elemData["Transform"]); } }
The counter and tmpcnt is there for grouping only and testing. Now to my problem of understanding.
I am saving the gameObjects in a different class:
and testing if the this variable is set with following statement:
this statement is only true when I either use a fixed variable pointing at the transform.Scene, create an object with Instantiate, but false when I use transform.Find. All 3 variations are Objects or not? Later I will be finding the sets dynamically over the name, so I will be using the find, but if this doesnt work, then I will need to plan something else. I wasnt sure if it had something todo with gameObject and transform, but converting the find result into a gameobject/transform didnt help.
I do hope someone can clear my misunderstanding on this point
asked Jun 09 '10 at 01:15 PM
Transform.Find returns the transform of the gameObject, while Instantiate returns a reference to the gameObject itself. To compare them you should do transform.Find("whatever").gameObject.
answered Jun 09 '10 at 01:20 PM