Unity3D - GameObject.Find() returning null for disabled object -


i have game object @ beginning of game disabled. want enable later via script. far have tried use following code:

gameobject.find("name").setactive (true); 

the problem game object @ beginning disabled when

gameobject.find("name") 

i null. don't know how activate it. it's canvas.

you can create class variable in script, , in unity scene editor assign disabled object class variable.

for example:

in script file, create class variable:

public gameobject objecttoenable; 

then, in scene editor, "objecttoenable" variable appear on script component of object containing script. drag disabled object variable (in scene editor) set reference.

once that, @ runtime can do:

objecttoenable.setactive(true); 

the reference should still valid, if object disabled.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -