private void OpenPageWorker(string scene, string page, object arg) { LDebugger.Log(this.GetType().ToString(), "OpenPageWork() scene:{0},page:{1},arg:{2} ", scene, page, arg); string oldScene = SceneManager.GetActiveScene().name; mCurrentPage = new UIPageTrack(); mCurrentPage.scene = scene; mCurrentPage.name = page; CloseAllLoadedPanels(); if (oldScene == scene) { Open <UIPage>(page, arg); } else { mOnSceneLoaded = (sceneName) => { if (sceneName.Equals(scene)) { mOnSceneLoaded = null; Open <UIPage>(page, arg); } }; SceneManager.LoadScene(scene); } }
public static GameObject LoadPrefab(string prefabName) { LDebugger.Log("UIRes::LoadPrefab ", UIResRoot + prefabName); GameObject asset = Resources.Load <GameObject>(UIResRoot + prefabName); return(asset); }
// Use this for initialization void Start() { UIAPI.ShowMsgBox("testTitle", "testContent", "yes|no|cancel", (args) => { LDebugger.Log(this.GetType().ToString(), "testMsgBox" + args); }); }
public void OpenPage(string scene, string page, object arg = null) { LDebugger.Log(this.GetType().ToString(), "OpenPage() scene:{0},page:{1},args:{2}", scene, page, arg); if (mCurrentPage != null) { mUIPageTrackStack.Push(mCurrentPage); } OpenPageWorker(scene, page, arg); }
public static void Save() { LDebugger.Log("GameConfig", "Save() Value=" + mConfig); if (mConfig != null) { byte[] data = PBSerializer.NSerialize(mConfig); FileUtils.SaveFile(Path, data); } }
public sealed override void Close(object args = null) { LDebugger.Log(GetType().ToString(), "Close()"); if (this.gameObject.activeSelf) { this.gameObject.SetActive(false); } OnClose(args); }
public sealed override void Open(object args = null) { LDebugger.Log(this.GetType().ToString(), "Open(),{0}", args); mOpenArgs = args; if (!this.gameObject.activeSelf) { this.gameObject.SetActive(true); } OnOpen(args); }
public static GameObject FindUIRoot() { GameObject root = GameObject.Find("UIRoot"); if (root != null && root.GetComponent <UIRoot>() != null) { return(root); } LDebugger.LogError(LOG_TAG, "FindUIRoot() UIRoot is not exist"); return(root); }
public static void ReleaseEntity(EntityObject obj) { if (obj != null) { if (EnableLog && LDebugger.EnableLog) { LDebugger.Log(LOG_TAG, "ReleaseEntity() {0}:{1}", obj.GetType().Name, obj.GetHashCode()); } obj.ReleaseInFactory(); } }
public void GoBackPage() { LDebugger.Log(this.GetType().ToString(), "GoBackPage()"); if (mUIPageTrackStack.Count > 0) { var track = mUIPageTrackStack.Pop(); OpenPageWorker(track.scene, track.name, null); } else if (mUIPageTrackStack.Count == 0) { EnterMainPage(); } }
public static void Init() { LDebugger.Log("GameConfig", "Init() Path=" + Path); byte[] data = FileUtils.ReadFile(Path); if (data != null && data.Length > 0) { GameConfig gameConfig = (GameConfig)PBSerializer.NDeserialize(data, typeof(GameConfig)); if (gameConfig != null) { mConfig = gameConfig; } } }
internal void HandleMessage(string msg, object[] args) { LDebugger.Log(GetType().ToString(), "HandleMessage(),msg:{0},args{1}", msg, args); MethodInfo methodInfo = this.GetType().GetMethod(msg, BindingFlags.NonPublic | BindingFlags.Instance); if (methodInfo != null) { methodInfo.Invoke(this, BindingFlags.NonPublic, null, args, null); } else { OnModuleMessage(msg, args); } }
protected void OnDisable() { LDebugger.Log(this.GetType().ToString(), "OnDisable()"); #if UNITY_EDITOR if (mIsOpenedOnce) { OnClose(); } #endif if (mGoBackButton != null) { mGoBackButton.onClick.RemoveAllListeners(); } }
protected void OnEnable() { LDebugger.Log(this.GetType().ToString(), "OnEnable"); if (mGoBackButton != null) { mGoBackButton.onClick.AddListener(OnGoBackButtonClicked); } #if UNITY_EDITOR if (mIsOpenedOnce) { OnOpen(mOpenArgs); } #endif }
private T Open <T>(string name, object arg = null) where T : UIPanel { T ui = Load <T>(name); if (ui != null) { ui.Open(arg); } else { LDebugger.LogError(this.GetType().ToString(), "Open() Failed! Name:{0}", name); } return(ui); }
public sealed override void Close(object args = null) { LDebugger.Log(this.GetType().ToString(), "Close() args= " + args); if (this.gameObject.activeSelf) { this.gameObject.SetActive(false); } OnClose(args); if (OnCloseEvent != null) { OnCloseEvent(args); OnCloseEvent = null; } }
public static void CreateView(string resPath, string resDefaultPath, EntityObject entity, Transform parent = null) { ViewObject obj = null; // string recycleType = resPath; bool userRecycler = true; obj = mRecycler.Pop(recycleType) as ViewObject; if (obj == null) { userRecycler = false; //TODO obj = InstanceViewFromPrefab(recycleType, resDefaultPath); } else { if (!obj.gameObject.activeSelf) { obj.gameObject.SetActive(true); } if (parent != null) { obj.transform.SetParent(parent, false); } else { obj.transform.SetParent(mViewRoot, false); } obj.CreateInFactory(entity, recycleType); if (EnableLog && LDebugger.EnableLog) { LDebugger.Log(LOG_TAG, "CreateView() {0}:{1}->{2}:{3},UseRecycler :{4}", entity.GetType().Name, entity.GetHashCode(), obj.GetRecycleType(), obj.GetInstanceID(), userRecycler); } if (mObjectsMap.ContainsKey(entity)) { LDebugger.LogError(LOG_TAG, "CreateView() 不应该存在重复的映射"); } mObjectsMap[entity] = obj; } }
private static ViewObject InstanceViewFromPrefab(string prefabName, string defaultPrefabName) { GameObject prefab = Resources.Load <GameObject>(prefabName); if (prefab == null) { prefab = Resources.Load <GameObject>(defaultPrefabName); } GameObject go = GameObject.Instantiate(prefab); ViewObject instance = go.GetComponent <ViewObject>(); if (instance == null) { LDebugger.LogError(LOG_TAG, "InstanceViewFromPrefab() prefab=" + prefabName); } return(instance); }
public static T InstanceEntity <T>() where T : EntityObject, new () { EntityObject obj = null; bool useRecycler = true; Type type = typeof(T); obj = mRecycler.Pop(type.FullName) as EntityObject; if (obj == null) { useRecycler = false; obj = new T(); } obj.InstanceInFactory(); if (EnableLog && LDebugger.EnableLog) { LDebugger.Log(LOG_TAG, "InstanceEntity() {0}:{1}, useRecycler:{2}", obj.GetType().Name, obj.GetHashCode(), useRecycler); } return((T)obj); }
public static void ReleaseView(EntityObject entity) { if (entity != null) { ViewObject obj = mObjectsMap[entity]; if (obj != null) { if (EnableLog && LDebugger.EnableLog) { LDebugger.Log(LOG_TAG, "ReleaseView() {0}:{1}->{2}:{3}", entity.GetType().Name, entity.GetHashCode(), obj.GetRecycleType(), obj.GetInstanceID()); } mObjectsMap.Remove(entity); obj.ReleaseInFactory(); obj.gameObject.SetActive(false); mRecycler.Push(obj); } } }
private T Load <T>(string name) where T : UIPanel { T ui = UIRoot.Find <T>(name); if (ui == null) { GameObject original = UIRes.LoadPrefab(name); if (original != null) { GameObject go = GameObject.Instantiate(original) as GameObject; ui = go.GetComponent <T>(); if (ui != null) { go.name = name; UIRoot.AddChild(ui); } else { LDebugger.LogError(this.GetType().ToString(), "Load() Prefab没有增加对应组件:" + name); } } else { LDebugger.LogError(this.GetType().ToString(), "Load() Res Not Found: " + name); } } if (ui != null) { if (mLoadedPanelList.IndexOf(ui) < 0) { mLoadedPanelList.Add(ui); } } return(ui); }
protected virtual void OnModuleMessage(string msg, object[] args) { LDebugger.Log(GetType().ToString(), "OnModuleMessage(),msg:{0},args:{1}", msg, args); }
private void OnGoBackButtonClicked() { LDebugger.Log(this.GetType().ToString(), "OnGoBackButtonClicked()"); //UIManager回退 UIManager.Instance.GoBackPage(); }
public virtual void Create(object args = null) { LDebugger.Log(GetType().ToString(), "Create() args={0}", args); }
private void OnWnd1Close(object arg) { LDebugger.Log(this.GetType().ToString(), "OnWnd1Close()"); }
//UI框架逻辑 public virtual void Open(object args = null) { LDebugger.Log(this.GetType().ToString(), "Open(),{0}", args); }
protected override void OnModuleMessage(string msg, object[] args) { base.OnModuleMessage(msg, args); LDebugger.Log(this.GetType().ToString(), "OnModuleMessage() msg:{0},args:{1},{2},{3}", msg, args[0], args[1], args[2]); }
protected void MessageFromA_2(string args0, int args1) { LDebugger.Log(this.GetType().ToString(), "MessageFromA_2() args:{0},{1}", args0, args1); }
private void OnLogin(bool args) { LDebugger.Log(this.GetType().ToString(), "OnLogin() args:{0}", args); }
private void OnModuleEventC(object args) { LDebugger.Log(this.GetType().ToString(), "OnModuleEventC() args:{0}", args); }