diff --git a/SHADE_Engine/src/Scene/SHSceneManager.h b/SHADE_Engine/src/Scene/SHSceneManager.h index 8f03b352..8f553703 100644 --- a/SHADE_Engine/src/Scene/SHSceneManager.h +++ b/SHADE_Engine/src/Scene/SHSceneManager.h @@ -219,10 +219,11 @@ namespace SHADE static void Exit() noexcept; static std::string GetSceneName() noexcept; - static void SetCurrentSceneName(std::string const& sceneName) noexcept; - 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 void SetCurrentSceneName(std::string const& sceneName) noexcept; + 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; } }; diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx index d3d989cc..3ffb72b2 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.cxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx @@ -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(); }