heres my code:
using UnityEngine;
using System.Collections;
public class barrackSpawner : MonoBehaviour
{
public Texture2D txture;
void Start()
{
}
void OnGUI()
{
Event e = Event.current;
if(e.isMouse)
{
Debug.Log("Barracks Menu Open");
// Make a background box
if(GUI.Button(new Rect(15,15,100,50),txture))
Debug.Log("Gui works");
}
}
}
the button doesnt display but i do get the debug message when i click on the right area.
i did search but didnt find anyone with similar problem.
The Button code needs to be executed during a EventType.Repaint to show. So to show you can do:
if(e.isMouse || e.type == EventType.Repaint)
What are you trying to do with restricting your button to mouse events?