Fixed awake() and start() getting called before all objects are loaded when changing scenes #266
|
@ -223,6 +223,7 @@ namespace SHADE
|
|||
static AssetID GetCurrentSceneAssetID() noexcept;
|
||||
//Only if scene doesn't exist, and scene asset id needs to be updated to the new one
|
||||
static void SetCurrentSceneAssetID(AssetID const& newAssetID);
|
||||
static bool HasSceneChanged() noexcept { return sceneChanged; }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -74,8 +74,9 @@ namespace SHADE
|
|||
// Add the script in
|
||||
script->Initialize(GameObject(entity));
|
||||
entityScriptList->Insert(System::Math::Clamp(index, 0, entityScriptList->Count), script);
|
||||
if (Application::IsPlaying)
|
||||
if (Application::IsPlaying && !SHSceneManager::HasSceneChanged())
|
||||
{
|
||||
// Only call immediately if we are in game and is not loading another scene
|
||||
script->Awake();
|
||||
script->Start();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue