Procházet zdrojové kódy

修复Entity Create的时候调用DeserializeSystem的问题
去掉一些高级语法,方便低版本Unity使用

tanghai před 4 roky
rodič
revize
04cdb7def2

+ 7 - 6
Unity/Assets/Hotfix/Demo/Move/M2C_PathfindingResultHandler.cs

@@ -11,14 +11,15 @@ namespace ET
 
 			float speed = unit.GetComponent<NumericComponent>().GetAsFloat(NumericType.Speed);
 
-			using var list = ListComponent<Vector3>.Create();
-			
-			for (int i = 0; i < message.Xs.Count; ++i)
+			using (var list = ListComponent<Vector3>.Create())
 			{
-				list.List.Add(new Vector3(message.Xs[i], message.Ys[i], message.Zs[i]));
-			}
+				for (int i = 0; i < message.Xs.Count; ++i)
+				{
+					list.List.Add(new Vector3(message.Xs[i], message.Ys[i], message.Zs[i]));
+				}
 
-			await unit.GetComponent<MoveComponent>().MoveToAsync(list.List, speed);
+				await unit.GetComponent<MoveComponent>().MoveToAsync(list.List, speed);
+			}
 		}
 	}
 }

+ 0 - 8
Unity/Assets/HotfixView/Demo/Helper.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 913c09549beec414789ff607d25ed736
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 8
Unity/Assets/Model/Core/Async.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 2fe5f2ece0bc94b59b709a814b1f00bd
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 25 - 4
Unity/Assets/Model/Core/Object/Entity.cs

@@ -275,8 +275,9 @@ namespace ET
                     }
                 }
 
-                if (preDomain == null)
+                if (!this.IsCreate)
                 {
+                    this.IsCreate = true;
                     EventSystem.Instance.Deserialize(this);
                 }
             }
@@ -293,7 +294,17 @@ namespace ET
 
         [IgnoreDataMember]
         [BsonIgnore]
-        public Dictionary<long, Entity> Children => this.children ??= childrenPool.Fetch();
+        public Dictionary<long, Entity> Children
+        {
+            get
+            {
+                if (this.children == null)
+                {
+                    this.children = childrenPool.Fetch();
+                }
+                return this.children;
+            }
+        }
 
         private void AddChild(Entity entity)
         {
@@ -326,7 +337,7 @@ namespace ET
                 return;
             }
 
-            this.childrenDB ??= hashSetPool.Fetch();
+            this.childrenDB = this.childrenDB ?? hashSetPool.Fetch();
 
             this.childrenDB.Add(entity);
         }
@@ -366,7 +377,17 @@ namespace ET
 
         [IgnoreDataMember]
         [BsonIgnore]
-        public Dictionary<Type, Entity> Components => this.components ??= dictPool.Fetch();
+        public Dictionary<Type, Entity> Components
+        {
+            get
+            {
+                if (this.components == null)
+                {
+                    this.components = dictPool.Fetch();
+                }
+                return this.components;
+            }
+        }
 
         public override void Dispose()
         {

+ 22 - 15
Unity/Assets/Model/Core/Object/EventSystem.cs

@@ -58,7 +58,11 @@ namespace ET
 		{
 			get
 			{
-				return instance ??= new EventSystem();
+				if (instance == null)
+				{
+					instance = new EventSystem();
+				}
+				return instance;
 			}
 		}
 		
@@ -532,24 +536,27 @@ namespace ET
 			{
 				return;
 			}
-			using var list = ListComponent<ETTask>.Create();
 
-			foreach (object obj in iEvents)
+			using (var list = ListComponent<ETTask>.Create())
 			{
-				if (!(obj is AEvent<T> aEvent))
+				foreach (object obj in iEvents)
 				{
-					Log.Error($"event error: {obj.GetType().Name}");
-					continue;
+					if (!(obj is AEvent<T> aEvent))
+					{
+						Log.Error($"event error: {obj.GetType().Name}");
+						continue;
+					}
+
+					list.List.Add(aEvent.Handle(a));
+				}
+				try
+				{
+					await ETTaskHelper.WaitAll(list.List);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
 				}
-				list.List.Add(aEvent.Handle(a));
-			}
-			try
-			{
-				await ETTaskHelper.WaitAll(list.List);
-			}
-			catch (Exception e)
-			{
-				Log.Error(e);
 			}
 		}
 

+ 0 - 8
Unity/Assets/Model/Module/MessageOuter.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: c6cefe3880e0c4df7a91259a5c228d85
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 8
Unity/Assets/Model/Module/Resource.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 194b25124176d48a7beeedf64e2a18f3
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 15 - 13
Unity/Assets/ModelView/Demo/Resource/ResourcesLoaderComponent.cs

@@ -9,23 +9,25 @@ namespace ET
         {
             async ETTask UnLoadAsync()
             {
-                using ListComponent<string> list = ListComponent<string>.Create();
-            
-                list.List.AddRange(self.LoadedResource);
-                self.LoadedResource = null;
-            
-                // 延迟5秒卸载包,因为包卸载是引用技术,5秒之内假如重新有逻辑加载了这个包,那么可以避免一次卸载跟加载
-                await TimerComponent.Instance.WaitAsync(5000);
-                
-                foreach (string abName in list.List)
+                using (ListComponent<string> list = ListComponent<string>.Create())
                 {
-                    using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.ResourcesLoader, abName.GetHashCode(), 0))
+                    list.List.AddRange(self.LoadedResource);
+                    self.LoadedResource = null;
+
+                    // 延迟5秒卸载包,因为包卸载是引用技术,5秒之内假如重新有逻辑加载了这个包,那么可以避免一次卸载跟加载
+                    await TimerComponent.Instance.WaitAsync(5000);
+
+                    foreach (string abName in list.List)
                     {
-                        if (ResourcesComponent.Instance == null)
+                        using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.ResourcesLoader, abName.GetHashCode(), 0))
                         {
-                            return;
+                            if (ResourcesComponent.Instance == null)
+                            {
+                                return;
+                            }
+
+                            await ResourcesComponent.Instance.UnloadBundleAsync(abName);
                         }
-                        await ResourcesComponent.Instance.UnloadBundleAsync(abName);
                     }
                 }
             }

+ 0 - 1
Unity/Packages/manifest.json

@@ -5,7 +5,6 @@
     "com.unity.assetbundlebrowser": "1.7.0",
     "com.unity.ide.rider": "2.0.7",
     "com.unity.ide.visualstudio": "2.0.11",
-    "com.unity.textmeshpro": "3.0.6",
     "com.unity.timeline": "1.4.8",
     "com.unity.ugui": "1.0.0",
     "com.unity.modules.ai": "1.0.0",