public void SetActive(bool active) { if (transform == null) { return; } if (active) { if (transform.gameObject.activeSelf == false) { transform.gameObject.SetActive(true); } Vector3 pos = transform.localPosition; pos.x = 0; pos.y = 0; transform.localPosition = pos; m_State = EWindowLoadState.Opening; OnStart(); SetLayer(); } else { Vector3 pos = transform.localPosition; pos.x = 20000; pos.y = 0; transform.localPosition = pos; m_State = EWindowLoadState.Hideing; OnClose(); } }
public void Destroy() { if (m_State == EWindowLoadState.None) { return; } OnDestroy(); if (gameObject != null) { gameObject.SetActive(false); UnityEngine.Object.Destroy(gameObject); transform = null; gameObject = null; } m_State = EWindowLoadState.None; }
public void HideAsync() { TargetID = null; if (m_State == EWindowLoadState.Opening || m_State == EWindowLoadState.Loading || m_State == EWindowLoadState.Hideing) { m_State = EWindowLoadState.Shuting; } switch (UnloadType) { case EUnloadType.Destroy: OnClose(); Destroy(); break; case EUnloadType.Visible: SetActive(false); break; } }
public void LoadAsync() { m_State = EWindowLoadState.Loading; GameObject go = null; if (IsResourceAsset) { go = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>(Path)); } else { //go = KGame.WorldManager.InstantiatePrefab(Path, Vector3.zero, Quaternion.identity, Vector3.one, Root.gameObject, false); } if (go == null) { Debug.LogError(string.Format("不存在窗口 {0} {1}", ID, Path)); return; } go.transform.SetParent(Root, false); this.gameObject = go; this.transform = go.transform; this.OnInitWidgets(); this.SetActive(true); }