using QFramework; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// /// ImageTarget 和对应显示物体 /// /// public class VuforialControl : MonoSingleton { public List list_Target = new List(); //public Text text1; //public Text text2; //public Text text3; private VuforialTargetMove oldTarget = null; private Transform oldTargetobj = null; public bool state; void Start() { state = false; oldTarget = null; // StartCoroutine(LoadARCamera(8)); // StartCoroutine(ReturnShaPan(17)); } /// /// 识别成功 /// /// 识别成功后Target物体 /// 对应的VuforialTargetMove /// VuforialTargetMove 对应的点 public void TrackingFound(Transform targetObj, int num , int pointnum) { try { state = true; if (list_Target.Count < (num + 1) || list_Target.Count < 1) return; ReplaceSceneSpoit(targetObj, num, pointnum); } catch (System.Exception) { ErrorLogPanel.Instance.Show(" 识别模块出现未知错误 "); } } public void TrackingLost(int num) { try { state = false; if (list_Target.Count < (num + 1) || list_Target.Count < 1) return; list_Target[num].Close(); // oldTargetobj = null; } catch (System.Exception) { ErrorLogPanel.Instance.Show(" 识别模块出现未知错误 "); } } public void ReplaceSceneSpoit(Transform targetObj, int num, int pointnum) { if (oldTarget == null) { oldTarget = list_Target[num]; oldTarget.Show(targetObj, pointnum); } else if (oldTarget == list_Target[num]) { // oldTarget.DirectClose(); oldTarget.ReplaceShow(targetObj, pointnum); } else if (oldTarget != list_Target[num]) { oldTarget.DirectClose(); oldTarget = list_Target[num]; oldTarget.Show(targetObj, pointnum); } GameManager.Instance.text2.text = oldTarget.name; } public void Close() { oldTarget = null; } IEnumerator LoadARCamera( float timer) { yield return new WaitForSeconds(timer); GameObject.Instantiate(Resources.Load("ARCamera")as GameObject ); GameManager.Instance.text.text = "ARCamera 加载成功"; // mrShaPan.transform.GetChild(0).GetComponent().Play("ReturnMrRoomFXAnimation"); // mrShaPan.SetActive(false); } /// /// 加载ARCamera /// public void LoadARCamera() { GameObject.Instantiate(Resources.Load("ARCamera") as GameObject); GameManager.Instance.text.text = "ARCamera 加载成功"; } //IEnumerator ReturnShaPan( float timer) //{ // yield return new WaitForSeconds(timer); // mrShaPan.SetActive(false); //} /// /// 退出显示 /// public void ExitShow() { oldTarget = null; oldTargetobj = null; } public void SetEditor(bool state) { if(state ) { for (int i = 0; i < list_Target.Count; i++) { list_Target[i].transform.position = Vector3.zero; list_Target[i].transform.eulerAngles = Vector3.zero; } } else { for (int i = 0; i < list_Target.Count; i++) { } } } }