|
@@ -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)
|