Beispiel #1
0
        public virtual IEnumerator LoadUIAsset(UILoadState loadState, UILoadRequest request)
        {
            string path        = string.Format("ui/{0}.prefab", loadState.TemplateName);
            var    assetLoader = StaticAssetLoader.Load(path);

            loadState.UIResourceLoader = assetLoader; // 基本不用手工释放的
            while (!assetLoader.IsCompleted)
            {
                yield return(null);
            }

            request.Asset = assetLoader.TheAsset;
        }
Beispiel #2
0
    void Awake()
    {
        uiFSM            = new UIFiniteStateMachine();
        uiPauseState     = new UIPauseState(this, uiPauseGO, uiPauseGO.GetComponentInChildren <ButtonGroup>());
        uiPlayState      = new UIPlayState(this, uiPlayGO);
        uiMainState      = new UIMainState(this, uiMainGO, uiMainGO.GetComponentInChildren <ButtonGroup>());
        uiSaveState      = new UISaveState(this, uiSaveGO, uiSaveGO.GetComponentInChildren <ButtonGroup>());
        uiLoadState      = new UILoadState(this, uiLoadGO, uiLoadGO.GetComponentInChildren <ButtonGroup>());
        uiEquipmentState = new UIEquipmentState(this, uiEquipmentGO);
        uiInventoryState = new UIInventoryState(this, uiInventoryGO);

        GM = GameObject.Find("GameManager").GetComponent <GameManager>();
    }
Beispiel #3
0
        public IEnumerator LoadUIAsset(UILoadState loadState, UILoadRequest request)
        {
            #if UNITY_5
            string path = string.Format("UI/{0}.prefab", loadState.TemplateName);
            #else
            string path = string.Format("UI/{0}_UI", loadState.TemplateName);
            #endif
            var assetLoader = StaticAssetLoader.Load(path);
            loadState.UIResourceLoader = assetLoader; // 基本不用手工释放的
            while (!assetLoader.IsCompleted)
                yield return null;

            request.Asset = assetLoader.TheAsset;
        }
        public static void ReloadUIAB(string uiName)
        {
            if (!EditorApplication.isPlaying)
            {
                Log.LogError("Reload UI only when your editor is playing!");
                return;
            }

            UILoadState state = null;

            if (UIModule.Instance.UIWindows.TryGetValue(uiName, out state))
            {
                var inOpenState = UIModule.Instance.IsOpen(uiName);
                if (inOpenState)
                {
                    UIModule.Instance.CloseWindow(uiName);
                }
#if xLua || SLUA
                var luaController = state.UIWindow as LuaUIController;
                if (luaController != null)
                {
                    luaController.ClearLuaTableCache(true);
                }
                UIModule.Instance.ReloadWindow(uiName, (args, err) =>
                {
                    if (inOpenState)
                    {
                        UIModule.Instance.OpenWindow(uiName, luaController.LastOnOpenArgs);
                    }
                });
#elif ILRuntime
                UIModule.Instance.ReloadWindow(uiName, (args, err) =>
                {
                    if (inOpenState)
                    {
                        UIModule.Instance.OpenWindow(uiName, (state.UIWindow as ILRuntimeUIBase)?.LastOnOpenArgs);
                    }
                });
#endif
            }
            else
            {
                Log.Info("UI:{0} 未打开过,无需处理", uiName);
            }
        }
        public static void ReloadUIScript(string uiName)
        {
            if (!EditorApplication.isPlaying)
            {
                Log.LogError("Reload UI only when your editor is playing!");
                return;
            }
            UILoadState state = null;

            if (UIModule.Instance.UIWindows.TryGetValue(uiName, out state))
            {
                var luaController = state.UIWindow as LuaUIController;
                if (luaController != null)
                {
                    luaController.ClearLuaTableCache(true);
                    luaController.OnInit();
                    luaController.OnOpen(luaController.LastOnOpenArgs);
                }
            }
            else
            {
                Log.Info("UI:{0} 未打开过,无需处理", uiName);
            }
        }