using UnityEngine; using Blue; public class LoadReference : AbstractController { public GameObject goRefrenceprefb; public GameObject goRefrence; private Transform meshTest=>(SceneIOCContainer.Instance.Pull("mesh_test")as GameObject).transform; private Transform meshTestParent=>(SceneIOCContainer.Instance.Pull("ARSpaceForAll")as GameObject).transform; private bool bool_GetReferencePosEvent=false; private bool bool_InitEvent=false; private Vector3 pos; private void Start() { this.RegisterEvent(GetObjOfRefrencePosRotSuccess).UnRegisterWhenGameObjectDestroyed(gameObject); this.RegisterEvent(InitEventSuccess).UnRegisterWhenGameObjectDestroyed(gameObject); } private void GetObjOfRefrencePosRotSuccess(GetReferencePosEvent e) { Debug.Log("DGJ GetObjOfRefrencePosRotSuccess ===> " + e.PosRot.x + " " + e.PosRot.y + " " + e.PosRot.z) ; bool_GetReferencePosEvent = true; pos = new Vector3(e.PosRot.x, e.PosRot.y, e.PosRot.z); if(bool_GetReferencePosEvent && bool_InitEvent) { SetPosRot(pos); } } private void InitEventSuccess(InitEvent e) { Debug.Log("DGJ InitEventSuccess ===> "); bool_InitEvent = true; if(bool_GetReferencePosEvent && bool_InitEvent) { SetPosRot(pos); } } private void SetPosRot(Vector3 pos) { if(goRefrence) Destroy(goRefrence); goRefrence = Instantiate(goRefrenceprefb, meshTest); goRefrence.name = "goRefrence"; SceneIOCContainer.Instance.Push("goRefrence",goRefrence); goRefrence.transform.localPosition = pos; goRefrence.transform.parent = meshTestParent; SetSceneActive.Instance.goReference_y = goRefrence.transform.position.y; goRefrence.SetActive(false); } }