From 13235abdc0c73ccc693448dd8c519fd3ae46fe19 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Sat, 19 Mar 2016 01:57:55 -0700 Subject: [PATCH] LoadScene uses variables --- .../Flowchart/Scripts/Commands/LoadScene.cs | 41 ++++++++++++++----- .../Flowchart/Scripts/Commands/OpenURL.cs | 6 +-- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs b/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs index 8fe57f47..864ead5c 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs @@ -1,43 +1,64 @@ using UnityEngine; +using UnityEngine.Serialization; using System; using System.Collections; namespace Fungus { [CommandInfo("Flow", - "Load Scene", - "Loads a new Unity scene and displays an optional loading image. This is useful " + - "for splitting a large game across multiple scene files to reduce peak memory " + - "usage. Previously loaded assets will be released before loading the scene to free up memory." + - "The scene to be loaded must be added to the scene list in Build Settings.")] + "Load Scene", + "Loads a new Unity scene and displays an optional loading image. This is useful " + + "for splitting a large game across multiple scene files to reduce peak memory " + + "usage. Previously loaded assets will be released before loading the scene to free up memory." + + "The scene to be loaded must be added to the scene list in Build Settings.")] [AddComponentMenu("")] - public class LoadScene : Command + public class LoadScene : Command, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("sceneName")] public string sceneNameOLD; + #endregion + [Tooltip("Name of the scene to load. The scene must also be added to the build settings.")] - public string sceneName = ""; + public StringData _sceneName = new StringData(""); [Tooltip("Image to display while loading the scene")] public Texture2D loadingImage; public override void OnEnter() { - SceneLoader.LoadScene(sceneName, loadingImage); + SceneLoader.LoadScene(_sceneName.Value, loadingImage); } public override string GetSummary() { - if (sceneName.Length == 0) + if (_sceneName.Value.Length == 0) { return "Error: No scene name selected"; } - return sceneName; + return _sceneName; } public override Color GetButtonColor() { return new Color32(235, 191, 217, 255); } + + // + // ISerializationCallbackReceiver implementation + // + + public virtual void OnBeforeSerialize() + {} + + public virtual void OnAfterDeserialize() + { + if (sceneNameOLD != default(string)) + { + _sceneName.Value = sceneNameOLD; + sceneNameOLD = default(string); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs b/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs index 2ebc8cdd..b92acf5f 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs @@ -11,18 +11,18 @@ namespace Fungus public class LinkToWebsite : Command { [Tooltip("URL to open in the browser")] - public string url; + public StringData url = new StringData(); public override void OnEnter() { - Application.OpenURL(url); + Application.OpenURL(url.Value); Continue(); } public override string GetSummary() { - return url; + return url.Value; } public override Color GetButtonColor()