Unity3d OnMouseDown不适用于GuitTexture
我已经花了最后一个小时试图找出如何使它,所以如果我的吉他是点击,一些事情会发生。我使用的是UnityScript,我认为它应该可以工作,但事实并非如此。此脚本应用于GuitTexture游戏对象Unity3d OnMouseDown不适用于GuitTexture,unity3d,unityscript,onmousedown,guitexture,Unity3d,Unityscript,Onmousedown,Guitexture,我已经花了最后一个小时试图找出如何使它,所以如果我的吉他是点击,一些事情会发生。我使用的是UnityScript,我认为它应该可以工作,但事实并非如此。此脚本应用于GuitTexture游戏对象 function OnMouseDown() { print("Button Clicked"); } 你不应该那样做。您只需制作一个GUI按钮并引用一个图像即可。就像下面的代码一样。 代码来自unity网站,我认为不需要解释: using UnityEngine; using System.
function OnMouseDown()
{
print("Button Clicked");
}
你不应该那样做。您只需制作一个GUI按钮并引用一个图像即可。就像下面的代码一样。 代码来自unity网站,我认为不需要解释:
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");
}
}