From 883a664b361d1ab9ea1445dcb1a924991bfa1be6 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期二, 27 十一月 2018 14:36:43 +0800
Subject: [PATCH] 3335 引入xlua

---
 System/WindowBase/WindowCenter.cs |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/System/WindowBase/WindowCenter.cs b/System/WindowBase/WindowCenter.cs
index 05e481e..9d5bac1 100644
--- a/System/WindowBase/WindowCenter.cs
+++ b/System/WindowBase/WindowCenter.cs
@@ -5,7 +5,7 @@
 namespace Snxxz.UI
 {
     [XLua.LuaCallCSharp]
-public class WindowCenter : Singleton<WindowCenter>
+    public class WindowCenter : Singleton<WindowCenter>
 
     {
         public event Action<Window> windowBeforeOpenEvent;
@@ -632,7 +632,7 @@
                 GetWindowInstanceAsync(_name,
                     (bool ok, UnityEngine.Object _object) =>
                     {
-                        if (TryGetWindow(out win))
+                        if (TryGetWindow(_name, out win))
                         {
                             if (win.windowState == Window.WindowState.Closed)
                             {
@@ -658,8 +658,8 @@
             Window window = null;
             if (TryGetWindow(name, out window))
             {
-                _win = window as T;
-                return true;
+                _win = windows[name] as T;
+                return _win != null;
             }
             else
             {
@@ -674,7 +674,7 @@
             if (windows.ContainsKey(_name))
             {
                 _win = windows[_name];
-                return true;
+                return _win != null;
             }
             else
             {
@@ -771,11 +771,12 @@
                     }
 
                     UILoader.UnLoadWindowAsset(prefabName);
-                    instance.name = _name;
-                    window = (Window)instance.GetComponent<Window>();
+                    window = instance.GetComponent<Window>();
+                    var typeName = window.GetType().Name;
+                    instance.name = typeName;
                     if (window != null)
                     {
-                        windows[_name] = (Window)window;
+                        windows[typeName] = window;
                     }
                     else
                     {

--
Gitblit v1.8.0