GameObject.Find(“guiTextures_1”).active = false;
is NOT working. Returning NullReferenceException
How to solve this problem? I have multiple page of comics in my game. I need to hide/show my comics page by page.
GameObject.Find(“guiTextures_1”).active = false;
is NOT working. Returning NullReferenceException
How to solve this problem? I have multiple page of comics in my game. I need to hide/show my comics page by page.
Code is in javascript. Basically you want “FindObjectsOfType” or something similar. I provided a for loop to show how to access all found objects.
var myGuiTextures : GUITexture[] = GameObject.FindObjectsOfType(typeof(GUITexture)) as GUITexture[];
for (var guiTexture:GUITexture in myGuiTextures) {
Debug.Log( guiTexture.name );
if (guiTexture.name == "guiTextures_1") guiTexture.active = false;
}
Thanks it works! Also, I’ve found another solution, which is
(GameObject.Find("myTexture").getComponent(GUITexture)as GUITexture).enable = false;
Thanks this script works! Also, I’ve just found another solution:
(GameObject.Find("myTexture1").getComponent(GUITexture)as GUITexture).enable = false;