Fixed bugs related to C# script serialization and deserialization #277
|
@ -74,7 +74,7 @@ namespace SHADE
|
|||
// Add the script in
|
||||
script->Initialize(GameObject(entity));
|
||||
entityScriptList->Insert(System::Math::Clamp(index, 0, entityScriptList->Count), script);
|
||||
if (Application::IsPlaying && !SHSceneManager::HasSceneChanged())
|
||||
if (Application::IsPlaying && !isDeserialising)
|
||||
{
|
||||
// Only call immediately if we are in game and is not loading another scene
|
||||
script->Awake();
|
||||
|
@ -423,6 +423,8 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
void ScriptStore::Init()
|
||||
{
|
||||
isDeserialising = false;
|
||||
|
||||
// Create an enumerable list of script types
|
||||
refreshScriptTypeList();
|
||||
// Get stored methods for interop variants of functions
|
||||
|
@ -724,6 +726,10 @@ namespace SHADE
|
|||
bool ScriptStore::DeserialiseScripts(Entity entity, System::IntPtr yamlNodePtr)
|
||||
{
|
||||
SAFE_NATIVE_CALL_BEGIN
|
||||
|
||||
// Flag that deserialization processs is ongoing
|
||||
isDeserialising = true;
|
||||
|
||||
// Convert to pointer
|
||||
YAML::Node* yamlNode = reinterpret_cast<YAML::Node*>(yamlNodePtr.ToPointer());
|
||||
|
||||
|
@ -765,9 +771,16 @@ namespace SHADE
|
|||
Debug::LogWarning("[ScriptStore] Script with unloaded type detected, skipping.");
|
||||
}
|
||||
}
|
||||
|
||||
// Unset flag for deserialization process
|
||||
isDeserialising = false;
|
||||
|
||||
return true;
|
||||
|
||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
|
||||
// Unset flag for deserialization process
|
||||
isDeserialising = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,6 +337,7 @@ namespace SHADE
|
|||
static ScriptSet disposalQueue;
|
||||
static System::Collections::Generic::IEnumerable<System::Type^>^ scriptTypeList;
|
||||
static System::Reflection::MethodInfo^ addScriptMethod;
|
||||
static bool isDeserialising;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
|
|
Loading…
Reference in New Issue