using LitJson; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using Vuforia; public class VufroiaTrigger { public JsonData msg; public UserSceneItem usi; public string xmlFile; public string datFile; public static string LoaclxmlFile; public static string LoacldatFile; bool isData; bool isXML; public void init() { xmlFile = msg["vuforiaXML"].ToString(); datFile = msg["vuforiaDat"].ToString(); LoaclxmlFile = Application.persistentDataPath + "/StreamingAssets/Vuforia/GHZVuforia.xml"; LoacldatFile = Application.persistentDataPath + "/StreamingAssets/Vuforia/GHZVuforia.dat"; Debug.Log(" DGJ ===> " + LoaclxmlFile); Debug.Log(" DGJ ===> " + LoacldatFile); LoadManager.Instance.loadVuforia(xmlFile, datFile,(bool b)=> { isXML = true; if(isData) { GameScene.Instance.StartCoroutine(loadVuforia()); } }, (bool b) => { isData = true; if (isXML) { GameScene.Instance.StartCoroutine(loadVuforia()); } }); } public void Clear() { isData = false; isXML = false; if (observer != null) { foreach (ObserverBehaviour item in observer) { GameManager.Instance.destroyGo(item.gameObject); } } } IEnumerable observer = null; IEnumerator loadVuforia() { isData = false; isXML = false; Debug.Log("DGJ ===> 加载Database " + LoaclxmlFile); observer = VuforiaBehaviour.Instance.ObserverFactory.CreateBehavioursFromDatabase(LoaclxmlFile); try { } catch (System.Exception e) { } yield return observer; // Create an Image Target from the database. if(observer !=null) { foreach (string item2 in usi.SpotsList.Keys) { foreach (var item111 in usi.SpotsList[item2].modelList.Keys) { for (int ij = 0; ij < usi.SpotsList[item2].modelList[item111].materialList.Count; ij++) { Debug.Log("測試===2=》" + usi.SpotsList[item2].modelList[item111].materialList[ij].name); Debug.Log("測試===2=》" + usi.SpotsList[item2].id + "_" + DataManager.Instance.ProjectID.ToString() + "_" + usi.id); Debug.Log("測試===2=》" + usi.SpotsList[item2].triggerImageMark); } } } foreach (ObserverBehaviour item in observer) { foreach (string item2 in usi.SpotsList.Keys) { Debug.Log("HJJVufroia 正在匹配" + item.TargetName+"_"+ usi.SpotsList[item2].triggerImageMark); if (item.TargetName == usi.SpotsList[item2].triggerImageMark) { Debug.Log("HJJVufroia 场景匹配成功"+ item.TargetName); usi.SpotsList[item2].setObVuforia(item); } } } } UIManager.Instance.HideUI(UINameConfig.LoadingPanel); UserSceneUI.Instance.obj.GetComponent().st.SetActive(true); } }