Преглед изворни кода

修复客户端组件为null,报错的问题

tanghai пре 8 година
родитељ
комит
f778193388
1 измењених фајлова са 6 додато и 3 уклоњено
  1. 6 3
      Unity/Assets/Scripts/Base/Object/Entity.cs

+ 6 - 3
Unity/Assets/Scripts/Base/Object/Entity.cs

@@ -203,10 +203,13 @@ namespace Model
 			{
 				this.components = null;
 			}
-			foreach (Component component in this.components)
+			if (this.components != null)
 			{
-				component.Owner = this;
-				this.componentDict.Add(component.GetType(), component);
+				foreach (Component component in this.components)
+				{
+					component.Owner = this;
+					this.componentDict.Add(component.GetType(), component);
+				}
 			}
 		}
 	}