From 6c324c5a811ce36d3da6cfb123f12ab7f00dd0bb Mon Sep 17 00:00:00 2001 From: Christopher Date: Wed, 9 Nov 2016 16:08:57 +0000 Subject: [PATCH] Save and Load flowchart state now working --- .../Fungus/Scripts/Commands/DeleteSaveKey.cs | 2 +- .../Fungus/Scripts/Commands/LoadFlowchart.cs | 89 +++ .../Scripts/Commands/LoadFlowchart.cs.meta | 12 + .../Fungus/Scripts/Commands/LoadVariable.cs | 2 +- .../Fungus/Scripts/Commands/SaveFlowchart.cs | 87 +++ ...avePoint.cs.meta => SaveFlowchart.cs.meta} | 0 Assets/Fungus/Scripts/Commands/SavePoint.cs | 103 ---- .../Fungus/Scripts/Commands/SaveVariable.cs | 2 +- .../Fungus/Scripts/Commands/SetSaveProfile.cs | 10 +- Assets/Fungus/Scripts/Editor/MenuEditor.cs | 6 +- .../Scripts/Editor/SaveFlowchartEditor.cs | 44 ++ .../Editor/SaveFlowchartEditor.cs.meta | 12 + Assets/Fungus/Scripts/Utils/SavePointData.cs | 99 +++- .../{SaveTests.unity => LoadFlowchart.unity} | 75 +-- Assets/Tests/Save/LoadFlowchart.unity.meta | 8 + Assets/Tests/Save/SaveFlowchart.unity | 554 ++++++++++++++++++ ...ts.unity.meta => SaveFlowchart.unity.meta} | 0 17 files changed, 955 insertions(+), 150 deletions(-) create mode 100644 Assets/Fungus/Scripts/Commands/LoadFlowchart.cs create mode 100644 Assets/Fungus/Scripts/Commands/LoadFlowchart.cs.meta create mode 100644 Assets/Fungus/Scripts/Commands/SaveFlowchart.cs rename Assets/Fungus/Scripts/Commands/{SavePoint.cs.meta => SaveFlowchart.cs.meta} (100%) delete mode 100644 Assets/Fungus/Scripts/Commands/SavePoint.cs create mode 100644 Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs create mode 100644 Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs.meta rename Assets/Tests/Save/{SaveTests.unity => LoadFlowchart.unity} (95%) create mode 100644 Assets/Tests/Save/LoadFlowchart.unity.meta create mode 100644 Assets/Tests/Save/SaveFlowchart.unity rename Assets/Tests/Save/{SaveTests.unity.meta => SaveFlowchart.unity.meta} (100%) diff --git a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs index 28626113..6b7559ac 100644 --- a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs +++ b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs @@ -30,7 +30,7 @@ namespace Fungus var flowchart = GetFlowchart(); // Prepend the current save profile (if any) - string prefsKey = SetSaveProfile.saveProfile + "_" + flowchart.SubstituteVariables(key); + string prefsKey = SetSaveProfile.SaveProfile + "_" + flowchart.SubstituteVariables(key); PlayerPrefs.DeleteKey(prefsKey); diff --git a/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs b/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs new file mode 100644 index 00000000..05f066c5 --- /dev/null +++ b/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs @@ -0,0 +1,89 @@ +// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). +// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) + +using UnityEngine; +using UnityEngine.SceneManagement; +using System.Collections.Generic; + +namespace Fungus +{ + [CommandInfo("Variable", + "Load Flowchart", + "Loads a previously saved Flowchart state. The original scene is loaded and the resume block is executed.")] + public class LoadFlowchart : Command + { + [Tooltip("Key for loading the saves data from PlayerPrefs. Supports variable subsitution {$VarName} and will prepend a profile name set using Set Save Profile command.")] + [SerializeField] protected StringData saveKey = new StringData("savedata"); + + protected SavePointData tempSaveData; + + protected virtual string CreateSaveKey() + { + var flowchart = GetFlowchart(); + var saveProfile = SetSaveProfile.SaveProfile; + + if (saveProfile.Length > 0) + { + return string.Format(saveProfile + "_" + flowchart.SubstituteVariables(saveKey.Value)); + } + else + { + return string.Format(flowchart.SubstituteVariables(saveKey.Value)); + } + } + + protected virtual string LoadJSONData(string key) + { + return PlayerPrefs.GetString(key); + } + + protected virtual void LoadSavedState(string jsonData) + { + tempSaveData = JsonUtility.FromJson(jsonData); + + SceneManager.sceneLoaded += OnSceneLoaded; + + // Load scene and wait + SceneManager.LoadScene(tempSaveData.sceneName); + } + + protected virtual void OnSceneLoaded(Scene scene, LoadSceneMode mode) + { + if (scene.name == tempSaveData.sceneName) + { + SavePointData.ResumeSavedState(tempSaveData); + } + + SceneManager.sceneLoaded -= OnSceneLoaded; + } + + #region Public members + + public override void OnEnter() + { + var key = CreateSaveKey(); + var jsonData = LoadJSONData(key); + + if (jsonData == "") + { + // Save data not found, continue executing block + Continue(); + return; + } + + LoadSavedState(jsonData); + } + + public override string GetSummary() + { + return saveKey.Value; + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs.meta b/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs.meta new file mode 100644 index 00000000..65916a89 --- /dev/null +++ b/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4bd5b7f5cc3944217aa05a6fa8552baf +timeCreated: 1478530280 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Scripts/Commands/LoadVariable.cs index 7c60e4d1..ecea1bab 100644 --- a/Assets/Fungus/Scripts/Commands/LoadVariable.cs +++ b/Assets/Fungus/Scripts/Commands/LoadVariable.cs @@ -38,7 +38,7 @@ namespace Fungus var flowchart = GetFlowchart(); // Prepend the current save profile (if any) - string prefsKey = SetSaveProfile.saveProfile + "_" + flowchart.SubstituteVariables(key); + string prefsKey = SetSaveProfile.SaveProfile + "_" + flowchart.SubstituteVariables(key); System.Type variableType = variable.GetType(); diff --git a/Assets/Fungus/Scripts/Commands/SaveFlowchart.cs b/Assets/Fungus/Scripts/Commands/SaveFlowchart.cs new file mode 100644 index 00000000..0c2be53f --- /dev/null +++ b/Assets/Fungus/Scripts/Commands/SaveFlowchart.cs @@ -0,0 +1,87 @@ +// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). +// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) + +using UnityEngine; +using UnityEngine.SceneManagement; +using System.Collections.Generic; + +namespace Fungus +{ + [CommandInfo("Variable", + "Save Flowchart", + "Saves the current Flowchart variable state to be loaded again in future.")] + public class SaveFlowchart : Command + { + [Tooltip("Key for storing save data in PlayerPrefs. Supports variable subsitution {$VarName} and will prepend a profile name set using Set Save Profile command.")] + [SerializeField] protected StringData saveKey = new StringData("savedata"); + + [SerializeField] protected Block resumeBlock; + + // Make serialize data extensible (subclassing?) + // Save key, use save profile and variable substitution + // Store scene name, flowchart name and block name to execute after load + // Show link to Block to be executed + + protected virtual string CreateSaveKey() + { + var flowchart = GetFlowchart(); + var saveProfile = SetSaveProfile.SaveProfile; + + if (saveProfile.Length > 0) + { + return string.Format(saveProfile + "_" + flowchart.SubstituteVariables(saveKey.Value)); + } + else + { + return string.Format(flowchart.SubstituteVariables(saveKey.Value)); + } + } + + protected virtual SavePointData CreateSaveData() + { + return SavePointData.Create(GetFlowchart(), resumeBlock.BlockName); + } + + protected virtual void StoreJSONData(string key, string jsonData) + { + if (key.Length > 0) + { + PlayerPrefs.SetString(key, jsonData); + } + } + + #region Public members + + public override void OnEnter() + { + var key = CreateSaveKey(); + + var saveData = CreateSaveData(); + var saveDataJSON = JsonUtility.ToJson(saveData, true); + + StoreJSONData(key, saveDataJSON); + + Continue(); + } + + public override string GetSummary() + { + return saveKey.Value; + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + + public override void GetConnectedBlocks(ref List connectedBlocks) + { + if (resumeBlock != null) + { + connectedBlocks.Add(resumeBlock); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SavePoint.cs.meta b/Assets/Fungus/Scripts/Commands/SaveFlowchart.cs.meta similarity index 100% rename from Assets/Fungus/Scripts/Commands/SavePoint.cs.meta rename to Assets/Fungus/Scripts/Commands/SaveFlowchart.cs.meta diff --git a/Assets/Fungus/Scripts/Commands/SavePoint.cs b/Assets/Fungus/Scripts/Commands/SavePoint.cs deleted file mode 100644 index f301e463..00000000 --- a/Assets/Fungus/Scripts/Commands/SavePoint.cs +++ /dev/null @@ -1,103 +0,0 @@ -// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). -// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) - -using UnityEngine; -using System.Collections.Generic; -using UnityEngine.SceneManagement; - -namespace Fungus -{ - [CommandInfo("Variable", - "Save Point", - "Saves current Flowchart state.")] - public class SavePoint : Command - { - [SerializeField] protected string restoreBlock; - - // Move serialization stuff into a seperate class - // Make serialize data extensible (subclassing?) - // Save key, use save profile and variable substitution - // Store scene name, flowchart name and block name to execute after load - // Show link to Block to be executed - - protected string CreateSaveData() - { - var saveData = new SavePointData(); - - var flowchart = GetFlowchart(); - - // Store the - saveData.sceneName = SceneManager.GetActiveScene().name; - saveData.flowchartName = flowchart.name; - saveData.blockName = ParentBlock.BlockName; - - for (int i = 0; i < flowchart.Variables.Count; i++) - { - var v = flowchart.Variables[i]; - - // Save string - var stringVariable = v as StringVariable; - if (stringVariable != null) - { - var d = new StringVar(); - d.key = stringVariable.Key; - d.value = stringVariable.Value; - saveData.stringVars.Add(d); - } - - // Save int - var intVariable = v as IntegerVariable; - if (intVariable != null) - { - var d = new IntVar(); - d.key = intVariable.Key; - d.value = intVariable.Value; - saveData.intVars.Add(d); - } - - // Save float - var floatVariable = v as FloatVariable; - if (floatVariable != null) - { - var d = new FloatVar(); - d.key = floatVariable.Key; - d.value = floatVariable.Value; - saveData.floatVars.Add(d); - } - - // Save bool - var boolVariable = v as BooleanVariable; - if (boolVariable != null) - { - var d = new BoolVar(); - d.key = boolVariable.Key; - d.value = boolVariable.Value; - saveData.boolVars.Add(d); - } - } - - return JsonUtility.ToJson(saveData, true); - } - - #region Public members - - public override void OnEnter() - { - var saveJSON = CreateSaveData(); - - Debug.Log(saveJSON); - } - - public override string GetSummary() - { - return ""; - } - - public override Color GetButtonColor() - { - return new Color32(235, 191, 217, 255); - } - - #endregion - } -} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SaveVariable.cs b/Assets/Fungus/Scripts/Commands/SaveVariable.cs index bbdc5a1f..43933880 100644 --- a/Assets/Fungus/Scripts/Commands/SaveVariable.cs +++ b/Assets/Fungus/Scripts/Commands/SaveVariable.cs @@ -42,7 +42,7 @@ namespace Fungus var flowchart = GetFlowchart(); // Prepend the current save profile (if any) - string prefsKey = SetSaveProfile.saveProfile + "_" + flowchart.SubstituteVariables(key); + string prefsKey = SetSaveProfile.SaveProfile + "_" + flowchart.SubstituteVariables(key); System.Type variableType = variable.GetType(); diff --git a/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs b/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs index bd6c5d60..2fa8f357 100644 --- a/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs +++ b/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs @@ -19,12 +19,14 @@ namespace Fungus [Tooltip("Name of save profile to make active.")] [SerializeField] protected string saveProfileName = ""; + /// + /// Shared save profile name used by SaveVariable and LoadVariable. + /// + private static string saveProfile = ""; + #region Public members - /// - /// Shared save profile name used by SaveVariable and LoadVariable. - /// - public static string saveProfile = ""; + public static String SaveProfile { get { return saveProfile; } } public override void OnEnter() { diff --git a/Assets/Fungus/Scripts/Editor/MenuEditor.cs b/Assets/Fungus/Scripts/Editor/MenuEditor.cs index 0ca3568e..c25ff420 100644 --- a/Assets/Fungus/Scripts/Editor/MenuEditor.cs +++ b/Assets/Fungus/Scripts/Editor/MenuEditor.cs @@ -44,9 +44,9 @@ namespace Fungus.EditorUtils EditorGUILayout.PropertyField(descriptionProp); BlockEditor.BlockField(targetBlockProp, - new GUIContent("Target Block", "Block to call when option is selected"), - new GUIContent(""), - flowchart); + new GUIContent("Target Block", "Block to call when option is selected"), + new GUIContent(""), + flowchart); EditorGUILayout.PropertyField(hideIfVisitedProp); EditorGUILayout.PropertyField(interactableProp); diff --git a/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs b/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs new file mode 100644 index 00000000..125a8a90 --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs @@ -0,0 +1,44 @@ +// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). +// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) + +using UnityEditor; +using UnityEngine; +using Fungus; + +namespace Fungus.EditorUtils +{ + [CustomEditor(typeof(SaveFlowchart))] + public class SaveFlowchartEditor : CommandEditor + { + protected SerializedProperty saveKeyProp; + protected SerializedProperty resumeBlockProp; + + protected virtual void OnEnable() + { + if (NullTargetCheck()) // Check for an orphaned editor instance + return; + + saveKeyProp = serializedObject.FindProperty("saveKey"); + resumeBlockProp = serializedObject.FindProperty("resumeBlock"); + } + + public override void DrawCommandGUI() + { + var flowchart = FlowchartWindow.GetFlowchart(); + if (flowchart == null) + { + return; + } + + serializedObject.Update(); + + EditorGUILayout.PropertyField(saveKeyProp); + BlockEditor.BlockField(resumeBlockProp, + new GUIContent("Resume Block", "Block to call when save data is loaded again"), + new GUIContent(""), + flowchart); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs.meta b/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs.meta new file mode 100644 index 00000000..f93633d0 --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 84d5f60f59d254712915dd59d345e0c6 +timeCreated: 1478701789 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Scripts/Utils/SavePointData.cs b/Assets/Fungus/Scripts/Utils/SavePointData.cs index a9a2a1db..0540c5ed 100644 --- a/Assets/Fungus/Scripts/Utils/SavePointData.cs +++ b/Assets/Fungus/Scripts/Utils/SavePointData.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; namespace Fungus { @@ -35,11 +37,106 @@ namespace Fungus { public string sceneName; public string flowchartName; - public string blockName; + public string resumeBlockName; public List stringVars = new List(); public List intVars = new List(); public List floatVars = new List(); public List boolVars = new List(); + + public static SavePointData Create(Flowchart flowchart, string resumeBlockName) + { + var saveData = new SavePointData(); + + // Store the scene, flowchart and block to execute on resume + saveData.sceneName = SceneManager.GetActiveScene().name; + saveData.flowchartName = flowchart.name; + saveData.resumeBlockName = resumeBlockName; + + for (int i = 0; i < flowchart.Variables.Count; i++) + { + var v = flowchart.Variables[i]; + + // Save string + var stringVariable = v as StringVariable; + if (stringVariable != null) + { + var d = new StringVar(); + d.key = stringVariable.Key; + d.value = stringVariable.Value; + saveData.stringVars.Add(d); + } + + // Save int + var intVariable = v as IntegerVariable; + if (intVariable != null) + { + var d = new IntVar(); + d.key = intVariable.Key; + d.value = intVariable.Value; + saveData.intVars.Add(d); + } + + // Save float + var floatVariable = v as FloatVariable; + if (floatVariable != null) + { + var d = new FloatVar(); + d.key = floatVariable.Key; + d.value = floatVariable.Value; + saveData.floatVars.Add(d); + } + + // Save bool + var boolVariable = v as BooleanVariable; + if (boolVariable != null) + { + var d = new BoolVar(); + d.key = boolVariable.Key; + d.value = boolVariable.Value; + saveData.boolVars.Add(d); + } + } + + return saveData; + } + + public static void ResumeSavedState(SavePointData saveData) + { + var go = GameObject.Find(saveData.flowchartName); + if (go == null) + { + return; + } + + var flowchart = go.GetComponent(); + if (flowchart == null) + { + return; + } + + for (int i = 0; i < saveData.boolVars.Count; i++) + { + var boolVar = saveData.boolVars[i]; + flowchart.SetBooleanVariable(boolVar.key, boolVar.value); + } + for (int i = 0; i < saveData.intVars.Count; i++) + { + var intVar = saveData.intVars[i]; + flowchart.SetIntegerVariable(intVar.key, intVar.value); + } + for (int i = 0; i < saveData.floatVars.Count; i++) + { + var floatVar = saveData.floatVars[i]; + flowchart.SetFloatVariable(floatVar.key, floatVar.value); + } + for (int i = 0; i < saveData.stringVars.Count; i++) + { + var stringVar = saveData.stringVars[i]; + flowchart.SetStringVariable(stringVar.key, stringVar.value); + } + + flowchart.ExecuteBlock(saveData.resumeBlockName); + } } } \ No newline at end of file diff --git a/Assets/Tests/Save/SaveTests.unity b/Assets/Tests/Save/LoadFlowchart.unity similarity index 95% rename from Assets/Tests/Save/SaveTests.unity rename to Assets/Tests/Save/LoadFlowchart.unity index d63f70ec..b951cc88 100644 --- a/Assets/Tests/Save/SaveTests.unity +++ b/Assets/Tests/Save/LoadFlowchart.unity @@ -302,14 +302,14 @@ GameObject: m_Component: - 4: {fileID: 1728985436} - 114: {fileID: 1728985435} - - 114: {fileID: 1728985434} - - 114: {fileID: 1728985433} - 114: {fileID: 1728985432} - 114: {fileID: 1728985431} - 114: {fileID: 1728985430} - 114: {fileID: 1728985429} - - 114: {fileID: 1728985437} - 114: {fileID: 1728985438} + - 114: {fileID: 1728985437} + - 114: {fileID: 1728985433} + - 114: {fileID: 1728985434} m_Layer: 0 m_Name: Flowchart m_TagString: Untagged @@ -376,43 +376,33 @@ MonoBehaviour: --- !u!114 &1728985433 MonoBehaviour: m_ObjectHideFlags: 2 - m_PrefabParentObject: {fileID: 11462346, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, - type: 2} + m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1728985428} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3} + m_Script: {fileID: 11500000, guid: 000864f8e9e1748a39807861d0e60e29, type: 3} m_Name: m_EditorClassIdentifier: - parentBlock: {fileID: 1728985434} - waitForFrames: 1 + parentBlock: {fileID: 1728985437} + keyPressType: 0 + keyCode: 108 --- !u!114 &1728985434 MonoBehaviour: - m_ObjectHideFlags: 2 - m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, - type: 2} + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1728985428} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Script: {fileID: 11500000, guid: 4bd5b7f5cc3944217aa05a6fa8552baf, type: 3} m_Name: m_EditorClassIdentifier: - nodeRect: - serializedVersion: 2 - x: 68 - y: 70 - width: 120 - height: 40 - tint: {r: 1, g: 1, b: 1, a: 1} - useCustomTint: 0 - itemId: 0 - blockName: New Block - description: - eventHandler: {fileID: 1728985433} - commandList: - - {fileID: 1728985437} + itemId: 5 + indentLevel: 0 + saveKey: + stringRef: {fileID: 0} + stringVal: savedata --- !u!114 &1728985435 MonoBehaviour: m_ObjectHideFlags: 0 @@ -433,12 +423,14 @@ MonoBehaviour: zoom: 0.98893297 scrollViewRect: serializedVersion: 2 - x: -343 - y: -340 - width: 1114 - height: 859 - selectedBlocks: [] - selectedCommands: [] + x: -368.287 + y: -369.7274 + width: 1216.2789 + height: 951.2311 + selectedBlocks: + - {fileID: 1728985437} + selectedCommands: + - {fileID: 1728985434} variables: - {fileID: 1728985432} - {fileID: 1728985431} @@ -476,12 +468,23 @@ MonoBehaviour: m_GameObject: {fileID: 1728985428} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0b115619cb83b4d6ab8047d0e9407403, type: 3} + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} m_Name: m_EditorClassIdentifier: - itemId: 1 - indentLevel: 0 - restoreBlock: + nodeRect: + serializedVersion: 2 + x: 103.50756 + y: 73.75383 + width: 120 + height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 + itemId: 4 + blockName: Load + description: + eventHandler: {fileID: 1728985433} + commandList: + - {fileID: 1728985434} --- !u!114 &1728985438 MonoBehaviour: m_ObjectHideFlags: 2 diff --git a/Assets/Tests/Save/LoadFlowchart.unity.meta b/Assets/Tests/Save/LoadFlowchart.unity.meta new file mode 100644 index 00000000..69623015 --- /dev/null +++ b/Assets/Tests/Save/LoadFlowchart.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 69eade49a291342f7a720011281fa97c +timeCreated: 1478534797 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Save/SaveFlowchart.unity b/Assets/Tests/Save/SaveFlowchart.unity new file mode 100644 index 00000000..8884fa38 --- /dev/null +++ b/Assets/Tests/Save/SaveFlowchart.unity @@ -0,0 +1,554 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 4 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_DirectLightInLightProbes: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &596180617 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 596180621} + - 114: {fileID: 596180620} + - 114: {fileID: 596180619} + - 114: {fileID: 596180618} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &596180618 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 596180617} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1997211142, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ForceModuleActive: 0 +--- !u!114 &596180619 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 596180617} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &596180620 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 596180617} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 5 +--- !u!4 &596180621 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 596180617} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 +--- !u!1 &668327051 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 668327056} + - 20: {fileID: 668327055} + - 92: {fileID: 668327054} + - 124: {fileID: 668327053} + - 81: {fileID: 668327052} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &668327052 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 668327051} + m_Enabled: 1 +--- !u!124 &668327053 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 668327051} + m_Enabled: 1 +--- !u!92 &668327054 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 668327051} + m_Enabled: 1 +--- !u!20 &668327055 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 668327051} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 + m_StereoMirrorMode: 0 +--- !u!4 &668327056 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 668327051} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!1 &1584700493 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1584700495} + - 114: {fileID: 1584700494} + m_Layer: 0 + m_Name: _FungusState + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1584700494 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1584700493} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3} + m_Name: + m_EditorClassIdentifier: + selectedFlowchart: {fileID: 1728985435} +--- !u!4 &1584700495 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1584700493} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1728985428 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1728985436} + - 114: {fileID: 1728985435} + - 114: {fileID: 1728985434} + - 114: {fileID: 1728985432} + - 114: {fileID: 1728985431} + - 114: {fileID: 1728985430} + - 114: {fileID: 1728985429} + - 114: {fileID: 1728985438} + - 114: {fileID: 1728985439} + - 114: {fileID: 1728985441} + - 114: {fileID: 1728985440} + - 114: {fileID: 1728985437} + m_Layer: 0 + m_Name: Flowchart + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1728985429 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5d02d9822eec54c98afe95bb497211b3, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: BoolVar + value: 1 +--- !u!114 &1728985430 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: afb91b566ceda411bad1e9d3c3243ecc, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: IntVar + value: 2 +--- !u!114 &1728985431 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 705fa1ac97df74e3a84ff952ffd923f1, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: FloatVar + value: 1 +--- !u!114 &1728985432 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4580f28dd8581476b810b38eea2f1316, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: StringVar + value: One +--- !u!114 &1728985434 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 68 + y: 70 + width: 120 + height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 + itemId: 0 + blockName: Save + description: + eventHandler: {fileID: 1728985440} + commandList: + - {fileID: 1728985441} +--- !u!114 &1728985435 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 1 + scrollPos: {x: 1.6562496, y: 1.0743227} + variablesScrollPos: {x: 0, y: 0} + variablesExpanded: 1 + blockViewHeight: 400 + zoom: 0.98893297 + scrollViewRect: + serializedVersion: 2 + x: -351.0967 + y: -353.54834 + width: 1199.0886 + height: 873.3693 + selectedBlocks: + - {fileID: 1728985434} + selectedCommands: [] + variables: + - {fileID: 1728985432} + - {fileID: 1728985431} + - {fileID: 1728985430} + - {fileID: 1728985429} + - {fileID: 1728985438} + description: + stepPause: 0 + colorCommands: 1 + hideComponents: 1 + saveSelection: 1 + localizationId: + showLineNumbers: 0 + hideCommands: [] + luaEnvironment: {fileID: 0} + luaBindingName: flowchart +--- !u!4 &1728985436 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 +--- !u!114 &1728985437 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ec422cd568a9c4a31ad7c36d0572b9da, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 4 + indentLevel: 0 + storyText: Resumed ok! + description: + character: {fileID: 0} + portrait: {fileID: 0} + voiceOverClip: {fileID: 0} + showAlways: 1 + showCount: 1 + extendPrevious: 0 + fadeWhenDone: 1 + waitForClick: 1 + stopVoiceover: 1 + setSayDialog: {fileID: 0} +--- !u!114 &1728985438 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4580f28dd8581476b810b38eea2f1316, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: StringVar2 + value: Two +--- !u!114 &1728985439 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 266.3094 + y: 70.72026 + width: 120 + height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 + itemId: 2 + blockName: Resume + description: + eventHandler: {fileID: 0} + commandList: + - {fileID: 1728985437} +--- !u!114 &1728985440 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 000864f8e9e1748a39807861d0e60e29, type: 3} + m_Name: + m_EditorClassIdentifier: + parentBlock: {fileID: 1728985434} + keyPressType: 0 + keyCode: 115 +--- !u!114 &1728985441 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1728985428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0b115619cb83b4d6ab8047d0e9407403, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 3 + indentLevel: 0 + saveKey: + stringRef: {fileID: 0} + stringVal: savedata + resumeBlock: {fileID: 1728985439} diff --git a/Assets/Tests/Save/SaveTests.unity.meta b/Assets/Tests/Save/SaveFlowchart.unity.meta similarity index 100% rename from Assets/Tests/Save/SaveTests.unity.meta rename to Assets/Tests/Save/SaveFlowchart.unity.meta