zhaoyang 3 anni fa
parent
commit
9ef744f67a

+ 1 - 2
GameClient/Assets/Game/HotUpdate/Views/Card/CardDetailView.cs

@@ -120,13 +120,11 @@ namespace GFGGame
         private void OnClickBtnBack()
         {
             ViewManager.GoBackFrom(ViewName.CARD_DETAIL_VIEW);
-            this.Clear();
         }
 
         private void OnClickBtnHome()
         {
             GameController.GoBackToMainView();
-            this.Clear();
 
         }
         private void Clear()
@@ -141,6 +139,7 @@ namespace GFGGame
         protected override void OnHide()
         {
             base.OnHide();
+            this.Clear();
             Timers.inst.Remove(CheckGuide);
         }
 

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Views/Common/Alert/Alert.cs

@@ -23,6 +23,7 @@ namespace GFGGame
                 _alertWindow = new AlertWindow();
             }
             _alertWindow.Reset();
+            _alertWindow.viewName = "AlertUI";
             _alertWindow.SetLayer(ConstViewLayer.TOP);
             _alertWindow.SetMessage(message);
             _alertWindow.Show();

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Views/Common/Alert/AlertSystem.cs

@@ -24,6 +24,7 @@ namespace GFGGame
             }
 
             _alertWindow.Reset();
+            _alertWindow.viewName = "AlertSystem";
             _alertWindow.SetLayer(ConstViewLayer.ALERT);
             _alertWindow.SetMessage(message);
             _alertWindow.Show();

+ 7 - 7
GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs

@@ -17,9 +17,9 @@ namespace GFGGame
         public override void Dispose()
         {
             _ui = null;
-            if (_scenePrefab != null)
+            if (_sceneObject != null)
             {
-                GameObject.Destroy(_scenePrefab);
+                GameObject.Destroy(_sceneObject);
                 _scenePrefab = null;
             }
             base.Dispose();
@@ -79,11 +79,11 @@ namespace GFGGame
         protected override void OnHide()
         {
 
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
+            // if (_sceneObject != null)
+            // {
+            //     GameObject.Destroy(_sceneObject);
+            //     _sceneObject = null;
+            // }
             base.OnHide();
         }
         protected override void RemoveEventListener()

+ 4 - 0
GameClient/Assets/Game/HotUpdate/Views/UIView.cs

@@ -17,6 +17,8 @@ namespace GFGGame
         /// 打开视图传递的参数
         /// </summary>
         public object viewData { get; set; }
+        public string viewName { get; set; }
+
 
         /// <summary>
         /// 设置视图组件
@@ -83,6 +85,7 @@ namespace GFGGame
             }
             _descFilePath = null;
             viewData = null;
+            ViewManager.ClearUIView(viewName);
         }
 
         virtual protected void Init()
@@ -205,6 +208,7 @@ namespace GFGGame
         void __removeFromStage()
         {
             OnHide();
+            // Dispose();
         }
 
     }

+ 30 - 5
GameClient/Assets/Game/HotUpdate/Views/ViewManager.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 using System.Collections.Generic;
 using System;
 using FairyGUI;
+using System.Linq;
 
 namespace GFGGame
 {
@@ -115,6 +116,7 @@ namespace GFGGame
             else
             {
                 obj = CreateViewInstance(viewName) as UIView;
+                obj.viewName = name;
                 _viewDic.Add(name, obj);
             }
             if (obj != null)
@@ -140,7 +142,7 @@ namespace GFGGame
                 {
                     _goBackDatas[name] = goBackParams;
                 }
-                Debug.Log("当前打开" + name);
+                Debug.Log("当前打开" + name);
 
             }
             return true;
@@ -185,6 +187,7 @@ namespace GFGGame
             else
             {
                 obj = new T() as UIView;
+                obj.viewName = name;
                 _viewDic.Add(name, obj);
             }
             if (obj != null)
@@ -285,16 +288,38 @@ namespace GFGGame
             }
             return null;
         }
+        public static void ClearUIView(string viewName)
+        {
+            if (_viewDic.ContainsKey(viewName))
+            {
+                if (_viewDic[viewName] != null && !_viewDic[viewName].isShowing)
+                {
+                    // _viewDic[viewName] = null;
+                    _viewDic.Remove(viewName);
+                }
+            }
+
+        }
         public static void HideAllView(string excludeViewName = null)
         {
-            foreach (string viewName in _viewDic.Keys)
+            for (int i = _viewDic.Keys.Count - 1; i >= 0; i--)//不用foreach是因为:循环过程中可能会触发dispose,导致_viewDic.Keys变化,最终报错
             {
-                if (viewName != excludeViewName)
+                KeyValuePair<string, UIView> kv = _viewDic.ElementAt(i);
+                if (kv.Key != excludeViewName)
                 {
-                    if (viewName == typeof(FunctionOpenView).Name) continue;//功能开启界面不能强制关闭
-                    Hide(viewName);
+                    if (kv.Key == typeof(FunctionOpenView).Name) continue;//功能开启界面不能强制关闭
+                    Hide(kv.Key);
                 }
             }
+            // _viewDic.Clear();
+            // foreach (string viewName in _viewDic.Keys)
+            // {
+            //     if (viewName != excludeViewName)
+            //     {
+            //         if (viewName == typeof(FunctionOpenView).Name) continue;//功能开启界面不能强制关闭
+            //         Hide(viewName);
+            //     }
+            // }
         }
 
         private static object CreateViewInstance(string name)

+ 3 - 3
GameClient/Assets/Game/Launcher/FairyGUI/GFGUIPackage.cs

@@ -41,13 +41,13 @@ namespace GFGGame
 
             if (_packages.TryGetValue(descFilePath, out package))
             {
-                _packages.Remove(package.name);
+                _packages.Remove(descFilePath);
                 UIPackage.RemovePackage(package.name);
 
                 List<Asset> list = null;
-                if(_assetDic.TryGetValue(descFilePath, out list))
+                if (_assetDic.TryGetValue(descFilePath, out list))
                 {
-                    foreach(var asset in list)
+                    foreach (var asset in list)
                     {
                         asset.Release();
                     }

+ 1 - 1
GameClient/Assets/ThirdParty/FairyGUI/Scripts/UI/GObject.cs

@@ -1110,7 +1110,7 @@ namespace FairyGUI
 
             set
             {
-                if (displayObject != null)
+                if (displayObject != null && displayObject.gameObject != null)
                     displayObject.gameObject.name = value;
             }
         }