Don't instantiate scripts for Editor + ScriptComponent Serialzation + Don't crash when scene loading failed

This commit is contained in:
Simon Lübeß
2023-07-17 01:27:58 +02:00
parent 76bff3a6c1
commit 1641bafd06
8 changed files with 373 additions and 148 deletions
+2 -4
View File
@@ -93,13 +93,11 @@ namespace GlitchyEngine.World
Entity targetEntity = target.GetEntityByID(sourceEntity.UUID);
ScriptComponent* targetComponent = targetEntity.AddComponent<ScriptComponent>();
targetComponent.Instance = new ScriptInstance(sourceComponent.Instance.ScriptClass);
targetComponent.Instance = new ScriptInstance(sourceComponent.ScriptClass);
targetComponent.Instance..ReleaseRef();
// We need an instance so we can copy the variables to it
// Initializes the created instance
ScriptEngine.InitializeInstance(targetEntity, targetComponent);
sourceComponent.Instance.CopyEditorFieldsTo(targetComponent.Instance);
}
// Copy transforms... needs special handling for the Parent<->Child relations