this is my first post to the community, until now, I just read a lot here, but for my current problem I don’t really find an answer. It’s a very simple problem, but I just cant find a solution.
I have 2 GUI Textures. The Second one should become visible on MouseOver, but only if the first one is already visible.
Here’s the code of the first texture which makes it visible when the user presses Escape
var showinapp=0;
function Update () {
if(Input.GetKeyUp(KeyCode.Escape)&&showinapp==0){
gameObject.GetComponent(GUITexture).enabled=true;
showinapp=1;
}
}
And here’s the code I tried for the second Texture
Here’s the problem: Making “showinapp” static breaks the code of the first script. It doesn’t produce any compiling errors, but the Texture doesn’t get active anymore if the user presses Escape.
Make sure to disable the Gui Texture before playing in the editor.
You don’t want to make the variable static. You will want to reference the first script that contains “showinapp” from the 2nd script:
public var ScriptName;
Then you will be able to access the variable “showinapp”.
Before clicking play drag the GUITexture that has the first script attached into the inspector of the GuiTexture that holds the second script. Otherwise you get a null reference exception.