Hey guys I was wondering is that possible to disabled an instantiate object? I instantiate a health bar in the game which is a guiTexture, and I want to disabled it when there is something between the camera and the object. It means that when player can't see that object, the health bar of the object won't come out. But is that even possible? THX~
Code (csharp): private GUITexture storedGUITexture; storedGUITexture = Instantiate (prefab, position, Quaternion.identity) as GUITexture; Make a place to store the texture reference then when it is created associate it with that storage and use that storage to reference it later to disable and enable it.
Uh....actually I have test it so many times. Here's my code: But I mean once when I instantiate guiTexture, it won't be disabled unless I destroy it. So that's where I stuck....
My reply is down there but a little dumb Q : how to post code like what you do in the reply? haha This is just the first time I'm asking a question here.
How about myHB.guiTexture = null;? or myHB.guiTexture.enabled = false; Also, objects aren't disabled, they are set inactive.