- Home /
I have been struggling with a GUI texture for over a week now. What am I doing wrong?
#pragma strict
/* Silence MonoBehaviour Warnings*/
private function SilenceWarnings() : void {
var al : ArrayList;
if(al == null);
var ae : AccelerationEvent;
if(ae == 0);
var dcm : DrawCameraMode;
if(dcm == 10) SilenceWarnings();
}
var menuState : int = 0;
var titleTex : GUITexture;
function Update () {
if ((Timer.timeCount >= 7) && (menuState == 0)) {
menuState = 1;
print(menuState);
}
if (menuState == 1) {
titleTex.enabled = true;
}
}
We usually don't copy your script and ran it in our PC. Please put in more details about your problem (What is expected, what had happened), then we will inspect your script to see which line might cause the problem.
I would remove that SilenceWarnings function before it infinite-loop crashes your Unity. If that's there to silence warnings caused by those particular variables, you might want to address those warnings elsewhere. They don't sound harmless :P
There's nothing wrong in your update, just be sure titleTex is in visible range of the camera.
Sorry about that. I'm trying to make a GUI texture appear on my screen and it doesn't appear at all. This is on an empty object so, if I'm not mistaken, the placement of the object in regards to the camera shouldn't matter. The texture appears when I enable it manually. So far I can't enable it through a script. I'll make the warning silencer a start function. It was to remove an annoying warning about not using system.collections.
If u don't $$anonymous$$d can please tell me correct requirement. so that will help u. Or else can please mail me ur requirement or project. i will see and if possible i will fix that and send to u. u can reach shankarraopilli@gmail.com or skype : shankar.clite
Answer by Shankar · Apr 01, 2013 at 05:19 PM
Hi Mr Dgoelitz,
please find this code once:
var isTextureVisible : boolean;
var someTexture : GUITexture;
function Update()
{
if(isTextureVisible)
someTexture.gameObject.active = true;
else
someTexture.gameObject.active = false;
}
if u want scene : https://www.dropbox.com/s/qeq8hq8yong32wn/GuiTexture.unitypackage
Awesome! It finally worked. I didn't know that I needed a boolean for this. Also It turned out that I had to have the checkbox in the texture marked, and setting it to active was something different. Shankar, I can't thank you enough.