- Home /
GUI and Application do no exist in the context
using System;
class ExampleClass
{
static void Main(){
if (GUI.Button(Rect(210,150,0,16)) == true)
{
Application.LoadLevel(Barracks);
return;
}
}
}
I dont quite know how to use the Rect() function, I am a fresh beginner in C#... Barracks is a Scene I have set up... This was all supposed to click on my 2D figure with scale (210,150,1) and position (0,16,154) I'd appreciate any possible help. Thanks.
Answer by PAEvenson · Feb 22, 2013 at 08:33 PM
you are not including:
using UnityEngine;
Also, GUI calls need to in the OnGUI() function and you most like want to derive your class from monobehavior, which C# does not do automatically. Take a look here for more info:
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html
oh wow, thanks man, I'll try to pay attention to what I import more...
Answer by Gabriel Quijada · Feb 22, 2013 at 09:40 PM
something is wrong over there, first you can see unity docs in the section of scripting.
the GUI.Button is a boolean, you don't need apply the equals operator and the other mistake is that you are creating bad the rect, the correct sentence be the next:
if (GUI.Button(new Rect(210,150,0,16)), "Change level")
{
Application.LoadLevel(Barracks);
return;
}
what if I wanted to use a shape I already had ins$$anonymous$$d of making a new Rect() like a gameObject named Sphere?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Is There A Way To Make Sprites Clickable? 1 Answer
UnityEngine.Input.GetMouseButton(1)) issue 1 Answer
How To Make GUI Buttons Load/Quit 1 Answer
GuiTexture Width Change 1 Answer