Kaynağa Gözat

RemoveComponent会调用GetComponent,结果触发了GetComponentSystem,这是不合理的

tanghai 2 yıl önce
ebeveyn
işleme
f621f2539c
1 değiştirilmiş dosya ile 7 ekleme ve 6 silme
  1. 7 6
      Unity/Assets/Scripts/Core/Entity/Entity.cs

+ 7 - 6
Unity/Assets/Scripts/Core/Entity/Entity.cs

@@ -591,8 +591,9 @@ namespace ET
             }
 
             Type type = typeof (K);
-            Entity c = this.GetComponent(type);
-            if (c == null)
+            
+            Entity c;
+            if (!this.components.TryGetValue(type.FullName, out c))
             {
                 return;
             }
@@ -613,8 +614,8 @@ namespace ET
                 return;
             }
 
-            Entity c = this.GetComponent(component.GetType());
-            if (c == null)
+            Entity c;
+            if (!this.components.TryGetValue(component.GetType().FullName, out c))
             {
                 return;
             }
@@ -635,8 +636,8 @@ namespace ET
                 return;
             }
 
-            Entity c = this.GetComponent(type);
-            if (c == null)
+            Entity c;
+            if (!this.components.TryGetValue(type.FullName, out c))
             {
                 return;
             }