0

I have spent the last hour trying to find out how to make it so if my GUITexture is clicked, something will happen. I am using UnityScript, and I thought this should work, but it doesn't. This script is applied to the GUITexture game object.

function OnMouseDown()
{
    print("Button Clicked");
}
user3071284
  • 6,955
  • 6
  • 43
  • 57
user2758663
  • 95
  • 1
  • 10

1 Answers1

0

you shouldnt do that. you can simply make a GUI BUTTON and refrence an image to it. like code bellow. the code is from unity website and i think it needs no explanation:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Texture btnTexture;
    void OnGUI() {
        if (!btnTexture) {
            Debug.LogError("Please assign a texture on the inspector");
            return;
        }
        if (GUI.Button(new Rect(10, 10, 50, 50), btnTexture))
            Debug.Log("Clicked the button with an image");

        if (GUI.Button(new Rect(10, 70, 50, 30), "Click"))
            Debug.Log("Clicked the button with text");

    }
}
virtouso
  • 549
  • 11
  • 30