mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Prevent double onAdd script call for GameBase objs
Adds a check to skip this the first time onNewDataBlock is called (when the object is created) to prevent double-calling onAdd
This commit is contained in:
parent
4db9d241bf
commit
4b678a3e3b
1 changed files with 9 additions and 4 deletions
|
|
@ -80,10 +80,15 @@ function spawnGameObject(%name, %addToScene)
|
||||||
|
|
||||||
function GameBaseData::onNewDataBlock(%this, %obj)
|
function GameBaseData::onNewDataBlock(%this, %obj)
|
||||||
{
|
{
|
||||||
if(%this.isMethod("onRemove"))
|
if (%obj.firstDataCheck)
|
||||||
%this.onRemove(%obj);
|
{
|
||||||
if(%this.isMethod("onAdd"))
|
if(%this.isMethod("onRemove"))
|
||||||
%this.onAdd(%obj);
|
%this.onRemove(%obj);
|
||||||
|
if(%this.isMethod("onAdd"))
|
||||||
|
%this.onAdd(%obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
%obj.firstDataCheck = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveGameObject(%name, %tamlPath, %scriptPath)
|
function saveGameObject(%name, %tamlPath, %scriptPath)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue