把canvas上的图片绑定到cube下
在需要隐藏的ui上绑定脚本 初始化的时候让其隐藏
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RawEditor : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
GameObject.Find("raw").SetActive(false);
}
// Update is called once per frame
void Update()
{
}
}
通过其他物体的状态判断页面上UI的隐藏与显示
void OnFind(VoidAREvent evt){
// Debug.Log(" ImageTargetBehaviour OnFind Event target:" + evt.currentTarget +" data = "+evt.data +" type = "+evt.name);
// print(" ImageTargetBehaviour OnFind Event target:" + evt.currentTarget + " data = " + evt.data + " type = " + evt.name);
//GameObject.Find("Canvas/Text").GetComponent<Text>().text= " ImageTargetBehaviour OnFind Event target:" + evt.currentTarget + " \n data = " + evt.data + "\n type = " + evt.name;
GameObject cube = GameObject.Find("Cube");
if (evt.name.Equals("findEvent"))
{
//显示图片
cube.transform.Find("info").gameObject.SetActive(true);
cube.transform.Find("raw").gameObject.SetActive(true);
}
else
{
//隐藏图片
cube.transform.Find("info").gameObject.SetActive(false);
cube.transform.Find("raw").gameObject.SetActive(false);
}
}
|