Save and Load script data from files

This commit is contained in:
Simon Lübeß
2024-01-07 18:35:33 +01:00
parent a302a26f80
commit bfc9d4a0a5
12 changed files with 994 additions and 224 deletions
+8 -2
View File
@@ -1023,7 +1023,7 @@ namespace GlitchyEditor
}
/// Sets the current editor scene
private void SetEditorScene(Scene scene)
private void SetEditorScene(Scene scene, Dictionary<UUID, SerializedObject> serializedObjects = null)
{
if (_editorScene != null)
{
@@ -1037,6 +1037,12 @@ namespace GlitchyEditor
if (_editorScene != null)
{
_editorScene.StartRuntime();
if (serializedObjects != null)
{
// Reconstruct state
ScriptEngine.DeserializeScriptInstances(serializedObjects);
}
}
}
@@ -1139,7 +1145,7 @@ namespace GlitchyEditor
// Make sure we actually loaded something!
if (result case .Ok)
{
SetEditorScene(newScene);
SetEditorScene(newScene, serializer.SerializedObjects);
String relativePath = scope .();
Path.GetRelativePath(filename, _currentProject.WorkspacePath, relativePath);