瀏覽代碼

Merge pull request #993 from AtomicWalrus/DoubleOnAddScriptFix_PR

Prevent double onAdd script call for GameBase objs
Brian Roberts 2 年之前
父節點
當前提交
5e9c99df67
共有 1 個文件被更改,包括 9 次插入4 次删除
  1. 9 4
      Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript

+ 9 - 4
Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript

@@ -80,10 +80,15 @@ function spawnGameObject(%name, %addToScene)
 
 function GameBaseData::onNewDataBlock(%this, %obj)
 {
-   if(%this.isMethod("onRemove"))
-      %this.onRemove(%obj);
-   if(%this.isMethod("onAdd"))
-      %this.onAdd(%obj);
+   if (%obj.firstDataCheck)
+   {
+      if(%this.isMethod("onRemove"))
+         %this.onRemove(%obj);
+      if(%this.isMethod("onAdd"))
+         %this.onAdd(%obj);
+   }
+   else
+      %obj.firstDataCheck = true;
 }
 
 function saveGameObject(%name, %tamlPath, %scriptPath)