public void Open <T>(Action <T> callback = null) where T : BaseWindow { SetTouchable(false); T t = Get <T>(); if (t) { mTmpWindowStack.Clear(); while (mWindowStack.Count > 0) { BaseWindow window = mWindowStack.Pop(); if (window == t) { break; } else { mTmpWindowStack.Push(window); } } while (mTmpWindowStack.Count > 0) { BaseWindow window = mTmpWindowStack.Pop(); mWindowStack.Push(window); } mTmpWindowStack.Clear(); Push(t, callback); } else { string path = WindowPath.Get <T>(); if (string.IsNullOrEmpty(path) == false) { /*string tmpAssetBundleName = "assetbundle.unity3d"; * AssetManager.GetSingleton().Load(tmpAssetBundleName, path, (varGo) => { * if (varGo) * { * GameObject go = AssetManager.Instantiate(tmpAssetBundleName, path, varGo); * * NGUITools.SetLayer(go, uiLayer); * * Transform tran = go.transform.Find(typeof(T).ToString()); * * tran.SetParent(uiRoot.transform); * * Destroy(go); * * tran.localPosition = Vector3.zero; * tran.localRotation = Quaternion.identity; * tran.localScale = Vector3.one; * * tran.gameObject.SetActive(true); * * * t = tran.GetComponent<T>(); * * if (t == null) t = tran.gameObject.AddComponent<T>(); * * if (t.windowType == WindowType.Root) * { * BaseWindow window = Get(WindowType.Root); * * if (window != null) * { * Destroy(tran.gameObject); * SetTouchable(true); * * return; * } * } * * t.path = path; * * t.OnEnter(); * * Push(t, callback); * } * else * { * SetTouchable(true); * } * }); */ GameObject asset = Resources.Load <GameObject>(path); if (asset) { GameObject go = Instantiate <GameObject>(asset); //NGUITools.SetLayer(go, uiLayer); Transform tran = go.transform.Find(typeof(T).ToString()); tran.SetParent(mCanvas.transform); Destroy(go); tran.localPosition = Vector3.zero; tran.localRotation = Quaternion.identity; tran.localScale = Vector3.one; tran.gameObject.SetActive(true); t = tran.GetComponent <T>(); if (t == null) { t = tran.gameObject.AddComponent <T>(); } if (t.windowType == WindowType.Root) { BaseWindow window = Get(WindowType.Root); if (window != null) { Destroy(tran.gameObject); SetTouchable(true); return; } } t.path = path; t.OnEnter(); Push(t, callback); } else { SetTouchable(true); } } else { SetTouchable(true); } } }
public void Open <T>(Action <T> callback = null) where T : BaseWindow { SetTouchable(false); T t = Get <T>(); if (t) { mTmpWindowStack.Clear(); while (mWindowStack.Count > 0) { BaseWindow window = mWindowStack.Pop(); if (window == t) { break; } else { mTmpWindowStack.Push(window); } } while (mTmpWindowStack.Count > 0) { BaseWindow window = mTmpWindowStack.Pop(); SetLayer(window); mWindowStack.Push(window); } mTmpWindowStack.Clear(); Push(t, callback); } else { string path = WindowPath.Get <T>(); if (string.IsNullOrEmpty(path) == false) { Load(path, (asset) => { if (asset) { GameObject go = Instantiate(asset) as GameObject; Transform tran = go.transform.Find(typeof(T).ToString()); tran.SetParent(mCanvas.transform); Destroy(go); tran.localPosition = Vector3.zero; tran.localRotation = Quaternion.identity; tran.localScale = Vector3.one; tran.gameObject.SetActive(true); t = tran.GetComponent <T>(); if (t == null) { t = tran.gameObject.AddComponent <T>(); } if (t.windowType == WindowType.Root) { BaseWindow window = Get(WindowType.Root); if (window != null) { Destroy(tran.gameObject); SetTouchable(true); if (callback != null) { callback(null); } return; } } t.path = path; t.OnEnter(); Push(t, callback); } else { SetTouchable(true); } }); } else { SetTouchable(true); } } }