- Home /
how can i fix this Really weird error
I have this script so when you hit a trigger attached to a weapon it will display a gui saying press V to equip. this is my script(i know i can use an OnGUI function but i don't know how to center it on the bottom for every game dimension(stand alone, 5:4, 4:3, etc.) if you could tell me how to do that instead that would work too):
var isGUIActive : boolean = false;
function OnTriggerEnter(hit : Collider) { if(hit.CompareTag("Player")) { isGUIActive = true; } }
function OnTriggerExit (hit : Collider) { if (hit.CompareTag("Player")) { isGUIActive = false; } }
function Update() { var gui = GameObject.Find("GUI_equip"); gui.guiTexture.texture = false;
if(isGUIActive)
{
gui.guiTexture.texture = true;
}
}
After i added this script i got this weird erroer:
InvalidProgramException: Invalid IL code in equip:Update (): IL_0012: castclass 0x01000006
What does that mean? can you tell me what is wrong?
Try putting this code under function OnGUI() ins$$anonymous$$d of Update.
Answer by Mike 3 · Feb 07, 2011 at 06:50 AM
gui.guiTexture.texture is how you set the texture on it
If you want to set it enabled/disabled, use gui.guiTexture.enabled = true;
Alternatively, use gui.active = true;
Dude thank you so much! I have been stuck on this for months!!!
Your answer
