Explorar o código

修复UI的bug

tanghai %!s(int64=5) %!d(string=hai) anos
pai
achega
3386099405

+ 1 - 1
Unity/Assets/Hotfix/Scene/LoginHelper.cs

@@ -25,7 +25,7 @@ namespace ET
 
                 Log.Info("登陆gate成功!");
 
-                await Game.EventSystem.Publish(new EventType.LoginFinish());
+                await Game.EventSystem.Publish(new EventType.LoginFinish() {ZoneScene = zoneScene});
             }
             catch (Exception e)
             {

+ 1 - 1
Unity/Assets/Hotfix/Scene/MapHelper.cs

@@ -26,7 +26,7 @@ namespace ET
 				
                 //Game.Scene.AddComponent<OperaComponent>();
 				
-                Game.EventSystem.Publish(new EventType.EnterMapFinish());
+                Game.EventSystem.Publish(new EventType.EnterMapFinish() {ZoneScene = zoneScene});
             }
             catch (Exception e)
             {

+ 2 - 1
Unity/Assets/HotfixView/Module/UI/UIComponentSystem.cs

@@ -14,10 +14,11 @@ namespace ET
 	/// </summary>
 	public static class UIComponentSystem
 	{
-		public static async ETTask Create(this UIComponent self, string uiType)
+		public static async ETTask<UI> Create(this UIComponent self, string uiType)
 		{
 			UI ui = await UIEventComponent.Instance.OnCreate(self, uiType);
 			self.UIs.Add(uiType, ui);
+			return ui;
 		}
 
 		public static void Remove(this UIComponent self, string uiType)

+ 2 - 4
Unity/Assets/HotfixView/UI/UIHelper.cs

@@ -4,14 +4,12 @@ namespace ET
     {
         public static async ETTask<UI> Create(Scene scene, string uiType)
         {
-            UIComponent uiComponent = scene.GetComponent<UIComponent>();
-            return await UIEventComponent.Instance.OnCreate(uiComponent, uiType);
+            return await scene.GetComponent<UIComponent>().Create(uiType);
         }
         
         public static async ETTask Remove(Scene scene, string uiType)
         {
-            UIComponent uiComponent = scene.GetComponent<UIComponent>();
-            UIEventComponent.Instance.OnRemove(uiComponent, uiType);
+            scene.GetComponent<UIComponent>().Remove(uiType);
         }
     }
 }

+ 1 - 1
Unity/Assets/HotfixView/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs

@@ -6,7 +6,7 @@ namespace ET
     {
         public override async ETTask Run(EventType.LoadingBegin args)
         {
-            await args.Scene.GetComponent<UIComponent>().Create(UIType.UILoading);
+            await UIHelper.Create(args.Scene, UIType.UILoading);
         }
     }
 }

+ 1 - 1
Unity/Assets/HotfixView/UI/UILoading/LoadingFinishEvent_RemoveLoadingUI.cs

@@ -4,7 +4,7 @@
     {
         public override async ETTask Run(EventType.LoadingFinish args)
         {
-            args.Scene.GetComponent<UIComponent>().Remove(UIType.UILoading);
+            await UIHelper.Create(args.Scene, UIType.UILoading);
         }
     }
 }

+ 0 - 1
Unity/Assets/HotfixView/UI/UILoading/UILoadingEvent.cs

@@ -27,7 +27,6 @@ namespace ET
 
         public override void OnRemove(UIComponent uiComponent)
         {
-	        uiComponent.Remove(UIType.UILoading);
         }
     }
 }

+ 1 - 1
Unity/Assets/HotfixView/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs

@@ -4,7 +4,7 @@
 	{
 		public override async ETTask Run(EventType.EnterMapFinish args)
 		{
-			Game.Scene.GetComponent<UIComponent>().Remove(UIType.UILobby);
+			await UIHelper.Remove(args.ZoneScene, UIType.UILobby);
 		}
 	}
 }

+ 1 - 1
Unity/Assets/HotfixView/UI/UILobby/LoginFinish_CreateLobbyUI.cs

@@ -6,7 +6,7 @@ namespace ET
 	{
 		public override async ETTask Run(EventType.LoginFinish args)
 		{
-			await Game.Scene.GetComponent<UIComponent>().Create(UIType.UILobby);
+			await UIHelper.Create(args.ZoneScene, UIType.UILobby);
 		}
 	}
 }

+ 3 - 4
Unity/Assets/HotfixView/UI/UILobby/UILobbyEvent.cs

@@ -8,9 +8,8 @@ namespace ET
     {
         public override async ETTask<UI> OnCreate(UIComponent uiComponent)
         {
-            ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
-            resourcesComponent.LoadBundle(UIType.UILobby.StringToAB());
-            GameObject bundleGameObject = (GameObject) resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby);
+            ResourcesComponent.Instance.LoadBundle(UIType.UILobby.StringToAB());
+            GameObject bundleGameObject = (GameObject) ResourcesComponent.Instance.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby);
             GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);
             UI ui = EntityFactory.CreateWithParent<UI, string, GameObject>(uiComponent, UIType.UILobby, gameObject);
 
@@ -20,7 +19,7 @@ namespace ET
 
         public override void OnRemove(UIComponent uiComponent)
         {
-            uiComponent.Remove(UIType.UILobby);
+            ResourcesComponent.Instance.UnloadBundle(UIType.UILobby.StringToAB());
         }
     }
 }

+ 3 - 4
Unity/Assets/HotfixView/UI/UILogin/UILoginEvent.cs

@@ -8,9 +8,8 @@ namespace ET
     {
         public override async ETTask<UI> OnCreate(UIComponent uiComponent)
         {
-            ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
-            await resourcesComponent.LoadBundleAsync(UIType.UILogin.StringToAB());
-            GameObject bundleGameObject = (GameObject) resourcesComponent.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin);
+            await ResourcesComponent.Instance.LoadBundleAsync(UIType.UILogin.StringToAB());
+            GameObject bundleGameObject = (GameObject) ResourcesComponent.Instance.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin);
             GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);
 
             UI ui = EntityFactory.CreateWithParent<UI, string, GameObject>(uiComponent, UIType.UILogin, gameObject);
@@ -21,7 +20,7 @@ namespace ET
 
         public override void OnRemove(UIComponent uiComponent)
         {
-            uiComponent.Remove(UIType.UILogin);
+            ResourcesComponent.Instance.UnloadBundle(UIType.UILogin.StringToAB());
         }
     }
 }

+ 1 - 0
Unity/Assets/Model/EventType.cs

@@ -38,6 +38,7 @@
 
         public struct EnterMapFinish
         {
+            public Scene ZoneScene;
         }
 
         public struct AfterUnitCreate