到目前为止,我有这个脚本:
Using UnityEngine;
using System.Collections;
public class text : MonoBehaviour {
public GameObject mainCam;
public bool showButton = false;
void OnGUI () {
// Make a background box
GUI.Box(new Rect(10,10,230,150), "Menu");
if (GameObject.Find("block1") && Input.GetMouseButtonDown(0)) {
showButton = true;
if(GUI.Button (new Rect (30,40,200,70), "Back to the blocks ")) {
print ("You clicked the button! The menu now appears");
mainCam.transform.position= new Vector3(-.13f, 0.87f, -8);
Camera.main.orthographicSize = 0.4f;
}
}
}
}
当视图位于多个块上时,我希望按钮被禁用或不活动,然后当我单击一个块并将我带到其中一个块的放大视图时,我希望 gui.button 出现。然后,如果我返回所有块的主视图,我希望再次禁用该按钮。我不知道该怎么做。