我试图在另一个对象上播放另一个脚本,当我按下GUI纹理时,我已经有了。
我试过GameObject.Find(theobject).GetComponent(thescript).enabled = true
,但它不起作用。我没有得到任何错误。只是当我按下GUI纹理时,它不做任何事情(顺便说一下,我在GUI纹理上有OnMouseDown()
函数)
有人能帮我吗?任何帮助都将非常感激。提前感谢!
编辑:按钮的脚本是:function OnMouseDown () {
GameObject.Find("TheObject").GetComponent(thescriptwithoutthespeachmarks).enabled = true
}
在Update()
函数中试试:
if(GUITexture.Contains(Input.MousePosition)){
if(Input.GetMouseButtonDown(0)){
GameObject.Find("TheObject").GetComponent(thescriptwithoutthespeachmarks).enabled = true;
}
}
试试这样
if(Input.GetMouseButtonDown(0)){
GameObject.Find("Objectname").GetComponent<Script>.enabled = true;
}