Quantcast
Channel: Answers for "GameObject.Find() work on inactive objects"
Browsing all 45 articles
Browse latest View live
↧

Answer by Eric5h5

GameObject.Find "This function only returns active gameobjects." You can reference inactive objects by using drag'n'drop in the inspector, or by finding active gameobjects and then deactivating them.

View Article


Answer by Antony Blackett

The solution only works if you don't rely on transform.root anywhere in your game. It also doesn't work if you need to find objects that are children of objects that don't get destroyed on load. Add a...

View Article


Answer by Bampf

Tranquility's [link he posted in the comments][1] contains an easy solution. Just keep an array of the disabled objects that you might want to find again. In the given code the author was bringing back...

View Article

Answer by Antony Blackett

Here's how you do it. Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[]; Note this can also return prefabs not just object instances in the scene so be careful when using it at edit time.

View Article

Answer by tavoevoe

Make sure you save a reference to the object before you set it to inactive.

View Article


Answer by bdawson

This is kind of gross, but it works well: public static List GetAllObjectsInScene(bool bOnlyRoot) { GameObject[] pAllObjects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject)); List...

View Article

Answer by akasurreal

FYI I wrote this and it worked for my purposes, I know it may not work for all. Look up the Unity docs on Resources.FindObjectsOfTypeAll to see some potential pitfalls. public class Helpers :...

View Article

Answer by Cawas

There are at very least 4 options: [`GetChild`](http://answers.unity3d.com/questions/30296/question-regarding-transformgetchild.html),...

View Article


Answer by Stalli

Here I need to find an child inactive object named "CheckPicture" of parent "objectParam". objectParam.GetComponentsInChildren().FirstOrDefault(component => component.gameObject.name ==...

View Article


Answer by Noob_Vulcan

Things that can find inactive gameObjects : transform.Find() or transform.FindChild() transform.GetComponentsInChildren(true) Resources.FindObjectsOfTypeAll() For more detail you can refer to...

View Article

Answer by RLAWLSGH

public static T[] FindObjectOfTypeIncludeInactivated() where T : Component{ List result = new List(); foreach( GameObject rootObj in...

View Article

Answer by CarterG81

> Does GameObject.Find() work on> inactive objects? If not, how do you> find and reference inactive objects. GameObject.Find() is only useful (good) in small scenes. Best practice is to avoid...

View Article

Answer by bburtson09

You Are looking for Resources.FindObjectsOfTypeAll(), as Noob_vulcan said. I wrote some test code and found many solutions, I will share 2 of my solutions the first being a broad implementation that is...

View Article


Answer by Eric5h5

GameObject.Find "This function only returns active gameobjects." You can reference inactive objects by using drag'n'drop in the inspector, or by finding active gameobjects and then deactivating them.

View Article

Answer by Antony-Blackett

The solution only works if you don't rely on transform.root anywhere in your game. It also doesn't work if you need to find objects that are children of objects that don't get destroyed on load. Add a...

View Article


Answer by Bampf

Tranquility's [link he posted in the comments][1] contains an easy solution. Just keep an array of the disabled objects that you might want to find again. In the given code the author was bringing back...

View Article

Answer by Antony-Blackett

Here's how you do it. Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[]; Note this can also return prefabs not just object instances in the scene so be careful when using it at edit time.

View Article


Answer by tavoevoe

Make sure you save a reference to the object before you set it to inactive.

View Article

Answer by bdawson

This is kind of gross, but it works well: public static List GetAllObjectsInScene(bool bOnlyRoot) { GameObject[] pAllObjects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject)); List...

View Article

Answer by akasurreal

FYI I wrote this and it worked for my purposes, I know it may not work for all. Look up the Unity docs on Resources.FindObjectsOfTypeAll to see some potential pitfalls. public class Helpers :...

View Article
Browsing all 45 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>