- Home /
Question by
felixwcf85 · Oct 31, 2012 at 09:29 AM ·
objectsguitexturefind
Find guiTexture objects by scripting
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.
Comment
what do you want? You have multiple answers with different object name.
Answer by Jessespike · Oct 31, 2012 at 10:06 AM
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;
}
Answer by felixwcf85 · Nov 01, 2012 at 05:52 AM
Thanks it works! Also, I've found another solution, which is
(GameObject.Find("myTexture").getComponent(GUITexture)as GUITexture).enable = false;
Answer by felixwcf85 · Nov 01, 2012 at 05:52 AM
Thanks this script works! Also, I've just found another solution:
(GameObject.Find("myTexture1").getComponent(GUITexture)as GUITexture).enable = false;
Your answer
![](https://koobas.hobune.stream/wayback/20220613083135im_/https://answers.unity.com/themes/thub/images/avi.jpg)