diff --git a/Assets/OkapiKit/Scripts/Base/OkapiValue.cs b/Assets/OkapiKit/Scripts/Base/OkapiValue.cs new file mode 100644 index 00000000..72a45a49 --- /dev/null +++ b/Assets/OkapiKit/Scripts/Base/OkapiValue.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace OkapiKit +{ + [System.Serializable] + public struct OkapiValue + { + public enum Type { Float = 0, Integer = 1, VariableInstance = 2, Variable = 3 }; + + [SerializeField] private bool init; + [SerializeField] private Type type; + [SerializeField] private VariableInstance variableInstance; + [SerializeField] private Variable variable; + [SerializeField] private float floatValue; + [SerializeField] private int intValue; + + public object GetRawValue() + { + switch (type) + { + case Type.Float: + return floatValue; + case Type.Integer: + return intValue; + case Type.VariableInstance: + return (variableInstance) ? (variableInstance.GetRawValue()) : (null); + case Type.Variable: + return (variable) ? (variable.GetRawValue()) : (null); + } + + return null; + } + + public string GetName() + { + switch (type) + { + case Type.Float: + break; + case Type.Integer: + break; + case Type.VariableInstance: + if (variableInstance != null) return variableInstance.name; + break; + case Type.Variable: + if (variable != null) return variable.name; + break; + default: + break; + } + + return "unnamed"; + } + } + + + [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] + public class OVNoLabelAttribute : PropertyAttribute + { + } + + [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] + public class OVNoFloatAttribute : PropertyAttribute + { + } + + [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] + public class OVNoIntegerAttribute : PropertyAttribute + { + } + + [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] + public class OVNoVariableInstanceAttribute : PropertyAttribute + { + } + + [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] + public class OVNoVariableAttribute : PropertyAttribute + { + } + + [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] + public class OVNoFunctionAttribute : PropertyAttribute + { + } +} diff --git a/Assets/OkapiKit/Scripts/Base/OkapiValue.cs.meta b/Assets/OkapiKit/Scripts/Base/OkapiValue.cs.meta new file mode 100644 index 00000000..f06b6f1a --- /dev/null +++ b/Assets/OkapiKit/Scripts/Base/OkapiValue.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9862ca3bb4b2736458949618e4988956 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/Deprecated.meta b/Assets/OkapiKit/Scripts/Deprecated.meta new file mode 100644 index 00000000..43a4164e --- /dev/null +++ b/Assets/OkapiKit/Scripts/Deprecated.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3ef933e4922335d4598c753cdce6d3f8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/Actions/ActionChangeValue_Deprecated.cs b/Assets/OkapiKit/Scripts/Deprecated/ActionChangeValue_Deprecated.cs similarity index 100% rename from Assets/OkapiKit/Scripts/Actions/ActionChangeValue_Deprecated.cs rename to Assets/OkapiKit/Scripts/Deprecated/ActionChangeValue_Deprecated.cs diff --git a/Assets/OkapiKit/Scripts/Actions/ActionChangeValue_Deprecated.cs.meta b/Assets/OkapiKit/Scripts/Deprecated/ActionChangeValue_Deprecated.cs.meta similarity index 100% rename from Assets/OkapiKit/Scripts/Actions/ActionChangeValue_Deprecated.cs.meta rename to Assets/OkapiKit/Scripts/Deprecated/ActionChangeValue_Deprecated.cs.meta diff --git a/Assets/OkapiKit/Scripts/Editor/ConditionDrawer.cs b/Assets/OkapiKit/Scripts/Editor/ConditionDrawer.cs index 40f9ed2c..8fad75ec 100644 --- a/Assets/OkapiKit/Scripts/Editor/ConditionDrawer.cs +++ b/Assets/OkapiKit/Scripts/Editor/ConditionDrawer.cs @@ -231,9 +231,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var r1 = propValueRect; r1.height = r1.height / 3; var r2 = r1; - r2.y = r1.bottom; + r2.y = r1.yMax; var r3 = r1; - r3.y = r2.bottom; + r3.y = r2.yMax; EditorGUI.PropertyField(r1, propComparisonValueHandler, GUIContent.none); EditorGUI.PropertyField(r2, propComparisonVariable, GUIContent.none); diff --git a/Assets/OkapiKit/Scripts/Editor/Deprecated.meta b/Assets/OkapiKit/Scripts/Editor/Deprecated.meta new file mode 100644 index 00000000..dc9bb712 --- /dev/null +++ b/Assets/OkapiKit/Scripts/Editor/Deprecated.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f92d96718077a44a80f70e229ce0979 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/Editor/ActionChangeValue_DeprecatedEditor.cs b/Assets/OkapiKit/Scripts/Editor/Deprecated/ActionChangeValue_DeprecatedEditor.cs similarity index 100% rename from Assets/OkapiKit/Scripts/Editor/ActionChangeValue_DeprecatedEditor.cs rename to Assets/OkapiKit/Scripts/Editor/Deprecated/ActionChangeValue_DeprecatedEditor.cs diff --git a/Assets/OkapiKit/Scripts/Editor/ActionChangeValue_DeprecatedEditor.cs.meta b/Assets/OkapiKit/Scripts/Editor/Deprecated/ActionChangeValue_DeprecatedEditor.cs.meta similarity index 100% rename from Assets/OkapiKit/Scripts/Editor/ActionChangeValue_DeprecatedEditor.cs.meta rename to Assets/OkapiKit/Scripts/Editor/Deprecated/ActionChangeValue_DeprecatedEditor.cs.meta diff --git a/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayEditor.cs b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayEditor.cs new file mode 100644 index 00000000..cd6838fc --- /dev/null +++ b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayEditor.cs @@ -0,0 +1,87 @@ +using UnityEngine; +using UnityEditor; + +namespace OkapiKit.Editor +{ + [CustomEditor(typeof(MultiValueDisplay))] + public class MultiValueDisplayEditor : OkapiBaseEditor + { + protected SerializedProperty propValues; + + protected virtual string typeOfDisplay { get; } + + protected override void OnEnable() + { + base.OnEnable(); + + propValues = serializedObject.FindProperty("values"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + if (WriteTitle()) + { + StdEditor(false); + } + } + + protected virtual void StdEditor(bool useOriginalEditor = true, bool isFinal = true) + { + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.PropertyField(propValues, new GUIContent("Values", "Values to display.\nFirst of these will replace {0} on the format string, the second will replace {1} and so forth."), true); + + if (isFinal) + { + EditorGUILayout.PropertyField(propDescription, new GUIContent("Description", "This is for you to leave a comment for yourself or others."), true); + + EditorGUI.EndChangeCheck(); + + serializedObject.ApplyModifiedProperties(); + (target as OkapiElement).UpdateExplanation(); + + // Draw old editor, need it for now + if (useOriginalEditor) + { + base.OnInspectorGUI(); + } + } + } + + protected override GUIStyle GetTitleSyle() + { + return GUIUtils.GetActionTitleStyle(); + } + + protected override GUIStyle GetExplanationStyle() + { + return GUIUtils.GetActionExplanationStyle(); + } + + protected override string GetTitle() + { + string varNames = "[UNDEFINED]"; + + // Get all var names + var t = target as MultiValueDisplay; + if (t != null) + { + varNames = t.GetVariableNames(); + } + + return $"Display {varNames} as {typeOfDisplay}"; + } + + protected override Texture2D GetIcon() + { + var varTexture = GUIUtils.GetTexture("VarDisplay"); + + return varTexture; + } + + protected override (Color, Color, Color) GetColors() => (GUIUtils.ColorFromHex("#fffaa7"), GUIUtils.ColorFromHex("#2f4858"), GUIUtils.ColorFromHex("#ffdf6e")); + + } +} \ No newline at end of file diff --git a/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayEditor.cs.meta b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayEditor.cs.meta new file mode 100644 index 00000000..49ba08b8 --- /dev/null +++ b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b485b471043dc9b4da4d124355e00d33 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayTextEditor.cs b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayTextEditor.cs new file mode 100644 index 00000000..b8ad1fe1 --- /dev/null +++ b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayTextEditor.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using UnityEditor; + +namespace OkapiKit.Editor +{ + [CustomEditor(typeof(MultiValueDisplayText))] + public class MultiValueDisplayTextEditor : MultiValueDisplayEditor + { + protected override string typeOfDisplay { get => "text"; } + + protected override void OnEnable() + { + base.OnEnable(); + } + + protected override void StdEditor(bool useOriginalEditor = true, bool isFinal = true) + { + base.StdEditor(useOriginalEditor, true); + } + + } +} \ No newline at end of file diff --git a/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayTextEditor.cs.meta b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayTextEditor.cs.meta new file mode 100644 index 00000000..43f7bb59 --- /dev/null +++ b/Assets/OkapiKit/Scripts/Editor/MultiValueDisplayTextEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c2762e16fe79c8f4f8b6157dd4fc84b3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/Editor/OkapiValueDrawer.cs b/Assets/OkapiKit/Scripts/Editor/OkapiValueDrawer.cs new file mode 100644 index 00000000..30b88d55 --- /dev/null +++ b/Assets/OkapiKit/Scripts/Editor/OkapiValueDrawer.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +namespace OkapiKit.Editor +{ + [CustomPropertyDrawer(typeof(OkapiValue))] + public class OkapiValueDrawer : PropertyDrawer + { + bool HasAttribute() where T : Attribute + { + T attr = attribute as T ?? fieldInfo.GetCustomAttribute(); + + return attr != null; + } + + bool labelEnabled => !HasAttribute(); + bool floatEnabled => !HasAttribute(); + bool integerEnabled => !HasAttribute(); + bool variableInstanceEnabled => !HasAttribute(); + bool variableEnabled => !HasAttribute(); + + // Draw the property inside the given rect + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + // Using BeginProperty / EndProperty on the parent property means that + // prefab override logic works on the entire property. + EditorGUI.BeginProperty(new Rect(position.x, position.y, position.width, position.height * 2), label, property); + + // Draw label - NO LABEL! + if (labelEnabled) + { + position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); + } + + // Don't make child fields be indented + var indent = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + + var propInit = property.FindPropertyRelative("init"); + var propType = property.FindPropertyRelative("type"); + var propFloat = property.FindPropertyRelative("floatValue"); + var propInt = property.FindPropertyRelative("intValue"); + var propVariableInstance = property.FindPropertyRelative("variableInstance"); + var propVariable = property.FindPropertyRelative("variable"); + + // Might need to initialize the value with some defaults + if (!propInit.boolValue) + { + propInit.boolValue = true; + + if (floatEnabled) + { + propType.enumValueIndex = (int)OkapiValue.Type.Float; + propFloat.floatValue = 0.0f; + } + else if (integerEnabled) + { + propType.enumValueIndex = (int)OkapiValue.Type.Integer; + propInt.intValue = 0; + } + else if (variableInstanceEnabled) + { + propType.enumValueIndex = (int)OkapiValue.Type.VariableInstance; + propVariableInstance.objectReferenceValue = null; + } + else if (variableEnabled) + { + propType.enumValueIndex = (int)OkapiValue.Type.Variable; + propVariable.objectReferenceValue = null; + } + + // Mark the entire object as dirty to ensure changes are saved + EditorUtility.SetDirty(property.serializedObject.targetObject); + + // Apply the modified properties to ensure changes are serialized + property.serializedObject.ApplyModifiedProperties(); + } + + var typeRect = position; + typeRect.width = typeRect.width * 0.25f; + + GetAvailableOptions(out var typeOptionStrings, out var typeOptionValues); + + int currentIndex = Array.IndexOf(typeOptionValues, (OkapiValue.Type)propType.enumValueIndex); + + int newIndex = EditorGUI.Popup(typeRect, GUIContent.none, currentIndex, typeOptionStrings); + + if (newIndex != currentIndex) + { + // Update the actual value on the script based on the selected option + propType.enumValueIndex = (int)typeOptionValues[newIndex]; + + // Mark the entire object as dirty to ensure changes are saved + EditorUtility.SetDirty(property.serializedObject.targetObject); + + // Apply the modified properties to ensure changes are serialized + property.serializedObject.ApplyModifiedProperties(); + } + + var valueRect = position; + valueRect.x = typeRect.xMax; + valueRect.width = valueRect.width * 0.75f; + + var type = (OkapiValue.Type)propType.enumValueIndex; + switch (type) + { + case OkapiValue.Type.Float: + EditorGUI.PropertyField(valueRect, propFloat, GUIContent.none); + break; + case OkapiValue.Type.Integer: + EditorGUI.PropertyField(valueRect, propInt, GUIContent.none); + break; + case OkapiValue.Type.VariableInstance: + EditorGUI.PropertyField(valueRect, propVariableInstance, GUIContent.none); + break; + case OkapiValue.Type.Variable: + EditorGUI.PropertyField(valueRect, propVariable, GUIContent.none); + break; + default: + break; + } + + // Set indent back to what it was + EditorGUI.indentLevel = indent; + + EditorGUI.EndProperty(); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + var baseHeight = base.GetPropertyHeight(property, label) + 2; + + return baseHeight; + } + + void GetAvailableOptions(out GUIContent[] typeOptionStrings, out OkapiValue.Type[] typeOptionValues) + { + var listTypeOptionStrings = new List(); + var listTypeOptionValues = new List(); + + if (floatEnabled) { listTypeOptionStrings.Add(new GUIContent("Float")); listTypeOptionValues.Add(OkapiValue.Type.Float); } + if (integerEnabled) { listTypeOptionStrings.Add(new GUIContent("Integer")); listTypeOptionValues.Add(OkapiValue.Type.Integer); } + if (variableInstanceEnabled) { listTypeOptionStrings.Add(new GUIContent("Variable Instance")); listTypeOptionValues.Add(OkapiValue.Type.VariableInstance); } + if (variableEnabled) { listTypeOptionStrings.Add(new GUIContent("Variable")); listTypeOptionValues.Add(OkapiValue.Type.Variable); } + + typeOptionStrings = listTypeOptionStrings.ToArray(); + typeOptionValues = listTypeOptionValues.ToArray(); + } + } +} \ No newline at end of file diff --git a/Assets/OkapiKit/Scripts/Editor/OkapiValueDrawer.cs.meta b/Assets/OkapiKit/Scripts/Editor/OkapiValueDrawer.cs.meta new file mode 100644 index 00000000..b0d540f6 --- /dev/null +++ b/Assets/OkapiKit/Scripts/Editor/OkapiValueDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ac3dea234c88e6c4ab19c78c70efd411 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/UI/MultiValueDisplay.cs b/Assets/OkapiKit/Scripts/UI/MultiValueDisplay.cs new file mode 100644 index 00000000..07cb66c2 --- /dev/null +++ b/Assets/OkapiKit/Scripts/UI/MultiValueDisplay.cs @@ -0,0 +1,68 @@ +using NaughtyAttributes; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace OkapiKit +{ + public class MultiValueDisplay : OkapiElement + { + [SerializeField, OVNoLabel, OVNoFloat, OVNoInteger, OVNoFunction] + protected OkapiValue[] values; + + public override string GetRawDescription(string ident, GameObject refObject) + { + return ""; + } + + protected override string Internal_UpdateExplanation() + { + _explanation = ""; + + if (description != "") _explanation += description + "\n----------------\n"; + + _explanation += GetRawDescription("", gameObject); + + return _explanation; + } + + public string GetVariableNames() + { + string ret = ""; + + if ((values == null) || (values.Length == 0)) + { + ret = "[UNDEFINED]"; + } + else + { + ret = "["; + for (int i = 0; i < values.Length; i++) + { + if (i > 0) ret += ", "; + ret += values[i].GetName(); + } + ret += "]"; + } + + return ret; + } + + protected object[] GetVariables() + { + List vars = new List(); + + foreach (var v in values) + { + vars.Add(v.GetRawValue()); + } + + return vars.ToArray(); + } + + protected override void CheckErrors() + { + base.CheckErrors(); + } + } +} \ No newline at end of file diff --git a/Assets/OkapiKit/Scripts/UI/MultiValueDisplay.cs.meta b/Assets/OkapiKit/Scripts/UI/MultiValueDisplay.cs.meta new file mode 100644 index 00000000..039cd745 --- /dev/null +++ b/Assets/OkapiKit/Scripts/UI/MultiValueDisplay.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5ff419c10d607b246ac972b6a006f2eb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 241012052d426af4887d2adcf629dfa2, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/UI/MultiValueDisplayText.cs b/Assets/OkapiKit/Scripts/UI/MultiValueDisplayText.cs new file mode 100644 index 00000000..929b4b58 --- /dev/null +++ b/Assets/OkapiKit/Scripts/UI/MultiValueDisplayText.cs @@ -0,0 +1,105 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using TMPro; +using NaughtyAttributes; +using System.ComponentModel; + +namespace OkapiKit +{ + [AddComponentMenu("Okapi/UI/Display Text (Multi)")] + public class MultiValueDisplayText : MultiValueDisplay + { + private string baseText; + + TextMeshProUGUI textGUI; + TextMeshPro textScene; + + void Start() + { + GetTarget(); + } + + bool GetTarget() + { + if ((textGUI == null) && (textScene == null)) + { + textGUI = GetComponent(); + if (textGUI) + { + baseText = textGUI.text; + } + else + { + textScene = GetComponent(); + if (textScene) + { + baseText = textScene.text; + } + } + if (baseText == "") baseText = "{0}"; + } + + return (textGUI != null) || (textScene != null); + } + + void Update() + { + var v = GetVariables(); + if (v == null) return; + if ((textGUI == null) && (textScene == null)) return; + + var txt = ""; + try + { + txt = string.Format(baseText, v); + } + catch + { + txt = $"[Invalid Formatter - {baseText}]"; + } + if (textGUI) textGUI.text = txt; + if (textScene) textScene.text = txt; + } + + public override string GetRawDescription(string ident, GameObject refObject) + { + string ret = $"This component displays the variables {GetVariableNames()} as text."; + if (!GetTarget()) + { + ret += "\nThere has to be a text component on this object with the C# text formatter string set."; + } + return ret; + } + + protected override void CheckErrors() + { + base.CheckErrors(); + + var textGUI = GetComponent(); + if (textGUI == null) + { + var textScene = GetComponent(); + if (textScene == null) + { + _logs.Add(new LogEntry(LogEntry.Type.Error, "Need to have a TextMeshPro or TextMeshProUGUI component on this object!", "To display some text, we need to have a TextMeshPro component (either TextMeshPro or TextMeshProUGUI, depending if it's part of a UI/canvas or the scene itself).")); + } + else + { + if ((textScene.text == "") || (textScene.text.IndexOf('{') == -1)) + { + _logs.Add(new LogEntry(LogEntry.Type.Warning, "Need to set the text of the component to a C# text formatter (like {0} or {0:D4})", "The text can incorporate other parts, only the part between { } will be replaced by the value itself and formatted according to the C# rules.")); + } + } + } + else + { + if ((textGUI.text == "") || (textGUI.text.IndexOf('{') == -1)) + { + _logs.Add(new LogEntry(LogEntry.Type.Warning, "Need to set the text of the component to a C# text formatter (like {0} or {0:D4})", "The text can incorporate other parts, only the part between { } will be replaced by the value itself and formatted according to the C# rules.")); + } + } + } + + } +} \ No newline at end of file diff --git a/Assets/OkapiKit/Scripts/UI/MultiValueDisplayText.cs.meta b/Assets/OkapiKit/Scripts/UI/MultiValueDisplayText.cs.meta new file mode 100644 index 00000000..59c086bd --- /dev/null +++ b/Assets/OkapiKit/Scripts/UI/MultiValueDisplayText.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2c80d88569a89340a3122230bb266c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 241012052d426af4887d2adcf629dfa2, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OkapiKit/Scripts/Variables/Variable.cs b/Assets/OkapiKit/Scripts/Variables/Variable.cs index f77289a1..fecab789 100644 --- a/Assets/OkapiKit/Scripts/Variables/Variable.cs +++ b/Assets/OkapiKit/Scripts/Variables/Variable.cs @@ -57,6 +57,13 @@ public void ResetValue() _currentValue = _defaultValue; } + public object GetRawValue() + { + if (_type == Type.Float) return _currentValue; + + return (int)_currentValue; + } + public void SetProperties(Type type, float currentValue, float defaultValue, bool hasLimits, float minValue, float maxValue) { this._type = type; diff --git a/Assets/OkapiKit/Scripts/Variables/VariableInstance.cs b/Assets/OkapiKit/Scripts/Variables/VariableInstance.cs index c7f13bb0..b80d7984 100644 --- a/Assets/OkapiKit/Scripts/Variables/VariableInstance.cs +++ b/Assets/OkapiKit/Scripts/Variables/VariableInstance.cs @@ -30,6 +30,17 @@ void Start() } public Variable.Type GetValueType() => type; + public object GetRawValue() + { + if (value) + { + return value.GetRawValue(); + } + + if (type == Variable.Type.Float) return currentValue; + + return (int)currentValue; + } public Variable GetVariable() { diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 9e0faeaf..cb7045c1 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,11 @@ # Release Notes +## V1.13.0 + +- Added multi-variable text display (you can now use as a formatter something like "XP {0}/{1}", and use a MultiValueDisplayText component to provide multiple variables) +- Created structure to allow for in the future variables, literals or functions to be used as values for most things (internals) +- Added deprecated directories for scripts that will eventually be phased out + ## V1.12.0 - Change Value action now can add/subtract a Variable/ValueHandler