Merge pull request #370 from SHADE-DP/SP3-6-c-scripting

Fixed behaviour of script Awake() and Start() not getting called as intended (first frame that object is active)
This commit is contained in:
XiaoQiDigipen 2023-02-27 13:10:35 +08:00 committed by GitHub
commit 725da6254d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -482,11 +482,20 @@ namespace SHADE
{
SAFE_NATIVE_CALL_BEGIN
// Clear the awake queue
for each (Script^ script in awakeList)
for each (Script ^ script in awakeList)
{
if (script->Owner.IsActiveInHierarchy)
{
script->Awake();
}
else
{
inactiveAwakeList.Add(script);
}
}
awakeList.Clear();
awakeList.UnionWith(%inactiveAwakeList);
inactiveAwakeList.Clear();
// Clear the start queue
for each (Script^ script in startList)
@ -501,10 +510,7 @@ namespace SHADE
}
}
startList.Clear();
for each (Script ^ script in startList)
{
startList.Add(script);
}
startList.UnionWith(%inactiveStartList);
inactiveStartList.Clear();
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")

View File

@ -353,6 +353,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
static ScriptDictionary scripts;
static ScriptSet awakeList;
static ScriptSet inactiveAwakeList;
static ScriptSet startList;
static ScriptSet inactiveStartList;
static ScriptSet disposalQueue;