diff --git a/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs b/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs index 81062ffb..c2cc139a 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs @@ -16,7 +16,7 @@ public Transform ParentTransform = null; [Tooltip("Settings string which describes the audio")] - public StringData _SettingsString = new StringData(""); + public StringDataMulti _SettingsString = new StringDataMulti(""); [Tooltip("Time to wait before executing the next command")] public float waitDuration = 0; diff --git a/Assets/Fungus/Flowchart/Editor/VariableEditor.cs b/Assets/Fungus/Flowchart/Editor/VariableEditor.cs index bd3b1c57..b64eabe5 100644 --- a/Assets/Fungus/Flowchart/Editor/VariableEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/VariableEditor.cs @@ -295,9 +295,13 @@ namespace Fungus public class FloatDataDrawer : VariableDataDrawer {} - [CustomPropertyDrawer (typeof(StringData))] - public class StringDataDrawer : VariableDataDrawer - {} + [CustomPropertyDrawer (typeof(StringData))] + public class StringDataDrawer : VariableDataDrawer + {} + + [CustomPropertyDrawer (typeof(StringDataMulti))] + public class StringDataMultiDrawer : VariableDataDrawer + {} [CustomPropertyDrawer (typeof(ColorData))] public class ColorDataDrawer : VariableDataDrawer diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs b/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs index 9b59c1b0..f9dfab95 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs @@ -20,7 +20,7 @@ namespace Fungus public DebugLogType logType; [Tooltip("Text to write to the debug log. Supports variable substitution, e.g. {$Myvar}")] - public StringData logMessage; + public StringDataMulti logMessage; public override void OnEnter () { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/If.cs b/Assets/Fungus/Flowchart/Scripts/Commands/If.cs index 21ac95ba..c7d67c4f 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/If.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/If.cs @@ -28,7 +28,7 @@ namespace Fungus public FloatData floatData; [Tooltip("String value to compare against")] - public StringData stringData; + public StringDataMulti stringData; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs index 282b7b9b..f85addd7 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs @@ -56,7 +56,7 @@ namespace Fungus public FloatEvent floatEvent = new FloatEvent(); [Tooltip("String parameter to pass to the invoked methods.")] - public StringData stringParameter; + public StringDataMulti stringParameter; [Tooltip("List of methods to call. Supports methods with one string parameter.")] public StringEvent stringEvent = new StringEvent(); diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs index 8317e589..e78cc37f 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs @@ -39,7 +39,7 @@ namespace Fungus public FloatData floatData; [Tooltip("String value to set with")] - public StringData stringData; + public StringDataMulti stringData; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs index 024e61cc..e6761018 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs @@ -30,6 +30,11 @@ namespace Fungus } } + /// + /// Can contain a reference to a StringVariable or a string constant. + /// Appears as a single line property in the inspector. + /// For a multi-line property, use StringDataMulti. + /// [System.Serializable] public struct StringData { @@ -37,7 +42,6 @@ namespace Fungus [VariableProperty("", typeof(StringVariable))] public StringVariable stringRef; - [TextArea(1,10)] [SerializeField] public string stringVal; @@ -71,4 +75,50 @@ namespace Fungus } } + /// + /// Can contain a reference to a StringVariable or a string constant. + /// Appears as a multi-line property in the inspector. + /// For a single-line property, use StringData. + /// + [System.Serializable] + public struct StringDataMulti + { + [SerializeField] + [VariableProperty("", typeof(StringVariable))] + public StringVariable stringRef; + + [TextArea(1,10)] + [SerializeField] + public string stringVal; + + public StringDataMulti(string v) + { + stringVal = v; + stringRef = null; + } + + public static implicit operator string(StringDataMulti spriteData) + { + return spriteData.Value; + } + + public string Value + { + get { return (stringRef == null) ? stringVal : stringRef.value; } + set { if (stringRef == null) { stringVal = value; } else { stringRef.value = value; } } + } + + public string GetDescription() + { + if (stringRef == null) + { + return stringVal; + } + else + { + return stringRef.key; + } + } + } + } \ No newline at end of file diff --git a/Assets/Fungus/UI/Scripts/Commands/SetText.cs b/Assets/Fungus/UI/Scripts/Commands/SetText.cs index df6db972..001c88c9 100644 --- a/Assets/Fungus/UI/Scripts/Commands/SetText.cs +++ b/Assets/Fungus/UI/Scripts/Commands/SetText.cs @@ -18,7 +18,7 @@ namespace Fungus [Tooltip("String value to assign to the text object")] [FormerlySerializedAs("stringData")] - public StringData text; + public StringDataMulti text; [Tooltip("Notes about this story text for other authors, localization, etc.")] public string description; diff --git a/Assets/Fungus/UI/Scripts/Commands/Write.cs b/Assets/Fungus/UI/Scripts/Commands/Write.cs index 8c2a5573..e1338cde 100644 --- a/Assets/Fungus/UI/Scripts/Commands/Write.cs +++ b/Assets/Fungus/UI/Scripts/Commands/Write.cs @@ -17,7 +17,7 @@ namespace Fungus public GameObject textObject; [Tooltip("String value to assign to the text object")] - public StringData text; + public StringDataMulti text; [Tooltip("Notes about this story text for other authors, localization, etc.")] public string description;