From d714de87d5b0a58324bcab7f6537afbd186df9ce Mon Sep 17 00:00:00 2001 From: m969 Date: Tue, 27 Oct 2020 11:33:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AFbug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20(#195)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复ReferenceCollector组件字段不能赋值的bug * 修复UILobbyComponentAwakeSystem获取ReferenceCollector组件报错的bug * 修复Unit预制体为空的bug * 调通客户端进map场景流程 --- Server/Hotfix/Demo/UnitPathComponentSystem.cs | 10 +- .../ReferenceCollectorEditor.cs | 2 +- .../Move/M2C_PathfindingResultHandler.cs | 3 +- Unity/Assets/Hotfix/Scene/MapHelper.cs | 18 +- .../Hotfix/Unit/M2C_CreateUnitsHandler.cs | 2 +- Unity/Assets/Hotfix/Unit/UnitFactory.cs | 2 +- Unity/Assets/HotfixView/AppStart_Init.cs | 3 +- .../UILobby/EnterMapFinish_RemoveLobbyUI.cs | 10 +- .../UI/UILobby/UILobbyComponentSystem.cs | 4 +- .../Unit/AfterUnitCreate_CreateUnitView.cs | 3 +- Unity/Assets/Model/Move.meta | 8 - Unity/Assets/Scenes/Init.unity | 3 +- Unity/Assets/Scenes/Map.unity | 355 ++- Unity/Packages/packages-lock.json | 34 +- Unity/Unity.Editor.csproj | 1290 +++++------ Unity/Unity.Hotfix.csproj | 1225 +++++------ Unity/Unity.HotfixView.csproj | 1249 +++++------ Unity/Unity.Model.csproj | 1495 ++++++------- Unity/Unity.ModelView.csproj | 1241 +++++------ Unity/Unity.ThirdParty.csproj | 1899 +++++++++-------- Unity/Unity.sln | 16 +- 21 files changed, 4567 insertions(+), 4305 deletions(-) delete mode 100644 Unity/Assets/Model/Move.meta diff --git a/Server/Hotfix/Demo/UnitPathComponentSystem.cs b/Server/Hotfix/Demo/UnitPathComponentSystem.cs index eb6ee1e7..7b846221 100644 --- a/Server/Hotfix/Demo/UnitPathComponentSystem.cs +++ b/Server/Hotfix/Demo/UnitPathComponentSystem.cs @@ -34,6 +34,14 @@ namespace ET self.Target = target; Unit unit = self.GetParent(); + unit.Position = target; + + M2C_PathfindingResult m2CPathfindingResult = new M2C_PathfindingResult(); + m2CPathfindingResult.X = unit.Position.x; + m2CPathfindingResult.Y = unit.Position.y; + m2CPathfindingResult.Z = unit.Position.z; + m2CPathfindingResult.Id = unit.Id; + MessageHelper.Broadcast(unit, m2CPathfindingResult); } // 从index找接下来3个点,广播 @@ -46,8 +54,6 @@ namespace ET m2CPathfindingResult.Y = unitPos.y; m2CPathfindingResult.Z = unitPos.z; m2CPathfindingResult.Id = unit.Id; - - MessageHelper.Broadcast(unit, m2CPathfindingResult); } } diff --git a/Unity/Assets/Editor/ReferenceCollectorEditor/ReferenceCollectorEditor.cs b/Unity/Assets/Editor/ReferenceCollectorEditor/ReferenceCollectorEditor.cs index fb614ac2..8ae1ea9b 100644 --- a/Unity/Assets/Editor/ReferenceCollectorEditor/ReferenceCollectorEditor.cs +++ b/Unity/Assets/Editor/ReferenceCollectorEditor/ReferenceCollectorEditor.cs @@ -104,7 +104,7 @@ public class ReferenceCollectorEditor: Editor property = dataProperty.GetArrayElementAtIndex(i).FindPropertyRelative("key"); EditorGUILayout.TextField(property.stringValue, GUILayout.Width(150)); property = dataProperty.GetArrayElementAtIndex(i).FindPropertyRelative("gameObject"); - EditorGUILayout.ObjectField(property.objectReferenceValue, typeof(Object), true); + property.objectReferenceValue = EditorGUILayout.ObjectField(property.objectReferenceValue, typeof(Object), true); if (GUILayout.Button("X")) { //将元素添加进删除list diff --git a/Unity/Assets/Hotfix/Move/M2C_PathfindingResultHandler.cs b/Unity/Assets/Hotfix/Move/M2C_PathfindingResultHandler.cs index e1759c58..b1cb3e3d 100644 --- a/Unity/Assets/Hotfix/Move/M2C_PathfindingResultHandler.cs +++ b/Unity/Assets/Hotfix/Move/M2C_PathfindingResultHandler.cs @@ -6,8 +6,7 @@ protected override async ETTask Run(Session session, M2C_PathfindingResult message) { Unit unit = session.Domain.GetComponent().Get(message.Id); - - + unit.GameObject.transform.position = unit.Position = new UnityEngine.Vector3(message.X, message.Y, message.Z); await ETTask.CompletedTask; } } diff --git a/Unity/Assets/Hotfix/Scene/MapHelper.cs b/Unity/Assets/Hotfix/Scene/MapHelper.cs index 92a498a5..8cc9db65 100644 --- a/Unity/Assets/Hotfix/Scene/MapHelper.cs +++ b/Unity/Assets/Hotfix/Scene/MapHelper.cs @@ -9,24 +9,8 @@ namespace ET { try { - /* - // 加载Unit资源 - ResourcesComponent resourcesComponent = Game.Scene.GetComponent(); - await resourcesComponent.LoadBundleAsync($"unit.unity3d"); - - // 加载场景资源 - await Game.Scene.GetComponent().LoadBundleAsync("map.unity3d"); - // 切换到map场景 - using (SceneChangeComponent sceneChangeComponent = Game.Scene.AddComponent()) - { - await sceneChangeComponent.ChangeSceneAsync(sceneName); - } - */ G2C_EnterMap g2CEnterMap = await zoneScene.GetComponent().Session.Call(new C2G_EnterMap()) as G2C_EnterMap; - - //Game.Scene.AddComponent(); - - Game.EventSystem.Publish(new EventType.EnterMapFinish() {ZoneScene = zoneScene}); + Game.EventSystem.Publish(new EventType.EnterMapFinish() {ZoneScene = zoneScene}).Coroutine(); } catch (Exception e) { diff --git a/Unity/Assets/Hotfix/Unit/M2C_CreateUnitsHandler.cs b/Unity/Assets/Hotfix/Unit/M2C_CreateUnitsHandler.cs index 6383410f..5a39816a 100644 --- a/Unity/Assets/Hotfix/Unit/M2C_CreateUnitsHandler.cs +++ b/Unity/Assets/Hotfix/Unit/M2C_CreateUnitsHandler.cs @@ -8,7 +8,7 @@ namespace ET { protected override async ETTask Run(Session session, M2C_CreateUnits message) { - UnitComponent unitComponent = Game.Scene.GetComponent(); + UnitComponent unitComponent = Game.Scene.Get(0).GetComponent(); foreach (UnitInfo unitInfo in message.Units) { diff --git a/Unity/Assets/Hotfix/Unit/UnitFactory.cs b/Unity/Assets/Hotfix/Unit/UnitFactory.cs index 0d9d85c1..0dd6777f 100644 --- a/Unity/Assets/Hotfix/Unit/UnitFactory.cs +++ b/Unity/Assets/Hotfix/Unit/UnitFactory.cs @@ -12,7 +12,7 @@ namespace ET Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit}); - UnitComponent unitComponent = Game.Scene.GetComponent(); + UnitComponent unitComponent = Game.Scene.Get(0).GetComponent(); unitComponent.Add(unit); return unit; } diff --git a/Unity/Assets/HotfixView/AppStart_Init.cs b/Unity/Assets/HotfixView/AppStart_Init.cs index 3ffdf62d..01c80267 100644 --- a/Unity/Assets/HotfixView/AppStart_Init.cs +++ b/Unity/Assets/HotfixView/AppStart_Init.cs @@ -21,8 +21,9 @@ namespace ET Game.Scene.AddComponent(); Game.Scene.AddComponent(); + ResourcesComponent.Instance.LoadBundle("unit.unity3d"); - Scene zoneScene = await SceneFactory.CreateZoneScene(1, 0, "Game"); + Scene zoneScene = await SceneFactory.CreateZoneScene(0, 0, "Game"); await Game.EventSystem.Publish(new EventType.AppStartInitFinish() { ZoneScene = zoneScene }); } diff --git a/Unity/Assets/HotfixView/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs b/Unity/Assets/HotfixView/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs index 8f7a9e7b..60f4b845 100644 --- a/Unity/Assets/HotfixView/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs +++ b/Unity/Assets/HotfixView/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs @@ -4,7 +4,15 @@ { public override async ETTask Run(EventType.EnterMapFinish args) { - await UIHelper.Remove(args.ZoneScene, UIType.UILobby); + // 加载场景资源 + await Game.Scene.GetComponent().LoadBundleAsync("map.unity3d"); + // 切换到map场景 + using (SceneChangeComponent sceneChangeComponent = Game.Scene.AddComponent()) + { + await sceneChangeComponent.ChangeSceneAsync("Map"); + } + Game.Scene.Get(0).AddComponent(); + await UIHelper.Remove(args.ZoneScene, UIType.UILobby); } } } diff --git a/Unity/Assets/HotfixView/UI/UILobby/UILobbyComponentSystem.cs b/Unity/Assets/HotfixView/UI/UILobby/UILobbyComponentSystem.cs index 2abc4a91..10ab34f4 100644 --- a/Unity/Assets/HotfixView/UI/UILobby/UILobbyComponentSystem.cs +++ b/Unity/Assets/HotfixView/UI/UILobby/UILobbyComponentSystem.cs @@ -7,7 +7,7 @@ namespace ET { public override void Awake(UILobbyComponent self) { - ReferenceCollector rc = self.GetParent().ViewGO.GetComponent(); + ReferenceCollector rc = self.GetParent().GameObject.GetComponent(); self.enterMap = rc.Get("EnterMap"); self.enterMap.GetComponent