c# - Find also in inactive gameobject -
this question has answer here:
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.
assuming game object has parent , have reference can use
transform.find
returnparentgameobject.transform.find("name").gameobject;
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
use serializedfield create editor reference
eg
[serializedfield] private gameobject myobject
- if need use find, have game object active initially, initialisation , store reference gameobject, make inactive.
Comments
Post a Comment