c# - Find also in inactive gameobject -


i using

gameobject.find("name"); 

but search in active gameobject there option avaiable search inactive object also.

i want search object name not tag name.

it not possible search inactive game objects name using gameobject.find. need find alternative solution.

here few simple ways find game object.

  1. assuming game object has parent , have reference can use transform.find return

    parentgameobject.transform.find("name").gameobject;

  2. gameobject.findobjectoftype<t>();

    this method slow , should never called in update

    you can find component type on game object use small scaffold component enable find object

  3. use serializedfield create editor reference

eg

[serializedfield] private gameobject myobject 
  1. if need use find, have game object active initially, initialisation , store reference gameobject, make inactive.

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -