- Home /
The question is answered, right answer was accepted
How Can i Find all gameobject in All scene
I want to make an option menu and make a toggle specular and etc. But i need to apply the settings for all gameobject in all scene.
Answer by sfc.itzhak · Jul 17, 2013 at 12:07 PM
to get all GameObjects
public GameObject[] AllGo;
// Use this for initialization
void Start () {
AllGo= GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
foreach (GameObject go in AllGo)
{
go.SendMessage("message");
}
}
But only in the current scene.I want to know how can i change every gameobject in the ALL scnenes
you cant; you need to save the data onta a gameobject that isnt destroyed on load DontDestroyOnLoad http://docs.unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html
then on scene load you invoke a function that dose the above on all GameObjects.
good Luck Sfc
Answer by ZBLau · May 17, 2016 at 04:16 AM
Transform[] arrTransforms = Resources.FindObjectsOfTypeAll().Where((s) => (s.hideFlags == HideFlags.None)).ToArray();