- Home /
Can't activate a prefab from an EditorWindow ?
Hi !
I have a problem with SetActive(), and I don't know how to solve this.
I have created a window for activate / desactivate gameobjects by tags. Hide objects was really easy and work perfectly with this script :
GameObject[] objectsList = GameObject.FindGameObjectsWithTag("MyTag") as GameObject[];
for (int currentId = 0; currentId < objectsList.Length; currentId++)
{
objectsList[currentId].SetActive(false);
}
So I need to reactivate ALL of the objects of the scene, so I've made a method with this :
GameObject[] objectsList = Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[];
for (int currentId = 0; currentId < objectsList.Length; currentId++)
{
objectsList[currentId].gameObject.SetActive(true);
}
Here is the problem : the gameobject are reactivated, but not the gameobject linked to a prefab (blue color on the Hierarchy). I've made many tests, but those log maybe should help :
GameObject[] objectsList = Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[];
for (int currentId = 0; currentId < objectsList.Length; currentId++)
{
objectsList[currentId].gameObject.SetActive(true);
Debug.Log(objectsList[currentId].gameObject.activeSelf);
}
The result was really clear : all gameobjects returns "true" event if they're not activated. I have tried to use SetDirty after the SetActive, but it doesn't change anything ...
Someone can help ?
Thank you !
Your answer
Follow this Question
Related Questions
SetActive true not working on UI object 2 Answers
text and image prefab not popping up when set.active 2 Answers
SetActive and prefabs not working 1 Answer
Set Active To Prefab 1 Answer
Viewpport for Custom Editor 1 Answer