|
Suppose you have a folder structure as follows: Scenes --> Scene_001 containing ( scene_1, script_1.js, SceneObject_1 ) I have attached the scripts to their respective scene objects; ie script_1 was drag connected to SceneObject_1, and so on. What I would like to do is have script_1 execute a function in script_2. I tried to use
as well as
to get a handle on the SceneObject_2. It simply can not find the object. So, how do we find game objects that are not in the same scene and not in the same folder?
(comments are locked)
|
|
There is no folder structure in the hierarchy; you can have objects be parents and children but they are all in one "folder". GameObject.Find will find any object in the scene by name regardless. It will not find any objects in different scenes, since those objects do not exist until they are loaded. Does this mean that scripts, game objects, and scenes must all reside at the same location in order to inter-operate? If so, doesn't this make larger projects harder to build and maintain if you can't partition the code base into logic sections. I'm definitely new to this environment, so I'd like to get off to a solid start. Thanks!
Mar 14 '10 at 10:45 PM
Kirkja
All assets for a project must be in the same project folder. You can make different folders in which to put scripts, prefabs, textures, etc., so you can organize a project however you want. Make sure you understand the difference between the project tab (everything in your project) and the hierarchy tab (all game objects in a given scene, which are the only things that GameObject.Find works with).
Mar 14 '10 at 11:48 PM
Eric5h5
(comments are locked)
|
