I have a script that generates a grid of prefab tile objects at runtime. I have attached a script to the prefab that contains a single Vector3 to store the grid coordinates of each tile as it's instantiated. How do I access the script component of the prefab from the script instantiating them? I've tried a bunch of different things, but they don't work because a prefab isn't a class.
Thanks for any help.
asked Mar 16 '11 at 12:27 AM
If I understand correctly, you'd do it just like any other object. Once instantiated, you can access the component (script) then anything in it: http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Components.htmland http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
The prefab isn't a class, it's an object, but you can get the component (script) off an object, thus stuff in that script.
If that doesn't do it for you, can you post some code?
answered Mar 16 '11 at 12:39 AM