diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs index ab1549230..f64601262 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs @@ -105,11 +105,8 @@ namespace HeavenStudio.Editor ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip)); } - Debug.Log(action.parameters); - foreach (var p in action.parameters) { - Debug.Log(p.collapseParams); if (p.collapseParams == null || p.collapseParams.Count == 0) continue; EventPropertyPrefab input = ePrefabs[p.propertyName].GetComponent(); foreach (var c in p.collapseParams) diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs index 606baf30b..551db89cd 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs @@ -14,6 +14,7 @@ namespace HeavenStudio.Editor public class EventPropertyPrefab : MonoBehaviour { public TMP_Text caption; + protected string _captionText; public EventParameterManager parameterManager; public string propertyName; public List propertyCollapses = new List(); @@ -25,7 +26,10 @@ namespace HeavenStudio.Editor { this.parameterManager = EventParameterManager.instance; this.propertyName = propertyName; - this.caption.text = caption; + + _captionText = caption; + + this.caption.text = _captionText; } public void UpdateCollapse(object type) @@ -34,7 +38,7 @@ namespace HeavenStudio.Editor { foreach (var c in p.collapseables) { - c.SetActive(p.collapseOn(type) && gameObject.activeSelf); + if (c != null) c.SetActive(p.collapseOn(type) && gameObject.activeSelf); } } } diff --git a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/BoolPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/BoolPropertyPrefab.cs index fa2d0e5e8..fb0eac664 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/BoolPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/BoolPropertyPrefab.cs @@ -18,15 +18,28 @@ namespace HeavenStudio.Editor [Space(10)] public Toggle toggle; + private bool _defaultValue; + new public void SetProperties(string propertyName, object type, string caption) { InitProperties(propertyName, caption); - // ' (bool)type ' always results in false + _defaultValue = (bool)type; toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]); toggle.onValueChanged.AddListener( - _ => parameterManager.entity[propertyName] = toggle.isOn + _ => + { + parameterManager.entity[propertyName] = toggle.isOn; + if (toggle.isOn != _defaultValue) + { + this.caption.text = _captionText + "*"; + } + else + { + this.caption.text = _captionText; + } + } ); } @@ -37,9 +50,5 @@ namespace HeavenStudio.Editor ); UpdateCollapse(toggle.isOn); } - - private void Update() - { - } } } \ No newline at end of file diff --git a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs index 1e36a1ee9..a7b894588 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs @@ -21,12 +21,26 @@ namespace HeavenStudio.Editor public bool colorTableActive; public ColorPreview colorPreview; + private Color _defaultColor; + new public void SetProperties(string propertyName, object type, string caption) { InitProperties(propertyName, caption); - colorPreview.colorPicker.onColorChanged += _ => + colorPreview.colorPicker.onColorChanged += _ => + { parameterManager.entity[propertyName] = colorPreview.colorPicker.color; + if (colorPreview.colorPicker.color != _defaultColor) + { + this.caption.text = _captionText + "*"; + } + else + { + this.caption.text = _captionText; + } + }; + + _defaultColor = (Color)type; Color paramCol = parameterManager.entity[propertyName]; diff --git a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/EnumPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/EnumPropertyPrefab.cs index f97ee0988..e205b5531 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/EnumPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/EnumPropertyPrefab.cs @@ -19,6 +19,8 @@ namespace HeavenStudio.Editor public TMP_Dropdown dropdown; private Array enumVals; + private int _defaultValue; + private bool openedDropdown = false; new public void SetProperties(string propertyName, object type, string caption) @@ -28,6 +30,7 @@ namespace HeavenStudio.Editor var enumType = type.GetType(); enumVals = Enum.GetValues(enumType); var enumNames = Enum.GetNames(enumType).ToList(); + _defaultValue = (int)type; // Can we assume non-holey enum? // If we can we can simplify to dropdown.value = (int) parameterManager.entity[propertyName] @@ -40,8 +43,18 @@ namespace HeavenStudio.Editor dropdown.AddOptions(enumNames); dropdown.value = selected; - dropdown.onValueChanged.AddListener(_ => - parameterManager.entity[propertyName] = (int) enumVals.GetValue(dropdown.value) + dropdown.onValueChanged.AddListener(_ => + { + parameterManager.entity[propertyName] = (int)enumVals.GetValue(dropdown.value); + if ((int)enumVals.GetValue(dropdown.value) != _defaultValue) + { + this.caption.text = _captionText + "*"; + } + else + { + this.caption.text = _captionText; + } + } ); } diff --git a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/NumberPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/NumberPropertyPrefab.cs index 15cdb6f21..a88f90fb5 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/NumberPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/NumberPropertyPrefab.cs @@ -9,6 +9,7 @@ using Starpelly; using HeavenStudio.Util; using HeavenStudio.Editor; +using static HeavenStudio.EntityTypes; namespace HeavenStudio.Editor { @@ -19,6 +20,8 @@ namespace HeavenStudio.Editor public Slider slider; public TMP_InputField inputField; + private float _defaultValue; + new public void SetProperties(string propertyName, object type, string caption) { InitProperties(propertyName, caption); @@ -28,6 +31,7 @@ namespace HeavenStudio.Editor case EntityTypes.Integer integer: slider.minValue = integer.min; slider.maxValue = integer.max; + _defaultValue = integer.val; slider.wholeNumbers = true; slider.value = Convert.ToSingle(parameterManager.entity[propertyName]); @@ -38,6 +42,14 @@ namespace HeavenStudio.Editor { inputField.text = slider.value.ToString(); parameterManager.entity[propertyName] = (int) slider.value; + if (slider.value != _defaultValue) + { + this.caption.text = _captionText + "*"; + } + else + { + this.caption.text = _captionText; + } } ); @@ -52,6 +64,14 @@ namespace HeavenStudio.Editor slider.value = Convert.ToSingle(inputField.text); parameterManager.entity[propertyName] = (int) slider.value; Editor.instance.editingInputField = false; + if (slider.value != _defaultValue) + { + this.caption.text = _captionText + "*"; + } + else + { + this.caption.text = _captionText; + } } ); break; @@ -59,6 +79,7 @@ namespace HeavenStudio.Editor case EntityTypes.Float fl: slider.minValue = fl.min; slider.maxValue = fl.max; + _defaultValue = fl.val; slider.value = Convert.ToSingle(parameterManager.entity[propertyName]); inputField.text = slider.value.ToString("G"); @@ -69,6 +90,14 @@ namespace HeavenStudio.Editor var newValue = (float) Math.Round(slider.value, 4); inputField.text = newValue.ToString("G"); parameterManager.entity[propertyName] = newValue; + if (newValue != _defaultValue) + { + this.caption.text = "*" + _captionText; + } + else + { + this.caption.text = _captionText; + } } ); @@ -83,6 +112,14 @@ namespace HeavenStudio.Editor slider.value = (float) Math.Round(Convert.ToSingle(inputField.text), 4); parameterManager.entity[propertyName] = slider.value; Editor.instance.editingInputField = false; + if (slider.value != _defaultValue) + { + this.caption.text = "*" + _captionText; + } + else + { + this.caption.text = _captionText; + } } ); break; diff --git a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/StringPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/StringPropertyPrefab.cs index ecae26ceb..8ea47db58 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/StringPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/StringPropertyPrefab.cs @@ -9,6 +9,7 @@ using Starpelly; using HeavenStudio.Util; using HeavenStudio.Editor; +using UnityEngine.UIElements; namespace HeavenStudio.Editor { @@ -18,10 +19,14 @@ namespace HeavenStudio.Editor [Space(10)] public TMP_InputField inputFieldString; + private string _defaultValue; + new public void SetProperties(string propertyName, object type, string caption) { InitProperties(propertyName, caption); + _defaultValue = (string)type; + inputFieldString.text = (string) parameterManager.entity[propertyName]; inputFieldString.onSelect.AddListener( @@ -30,10 +35,19 @@ namespace HeavenStudio.Editor ); inputFieldString.onValueChanged.AddListener( _ => - {; + { parameterManager.entity[propertyName] = inputFieldString.text; + if (inputFieldString.text != _defaultValue) + { + this.caption.text = _captionText + "*"; + } + else + { + this.caption.text = _captionText; + } } ); + inputFieldString.onEndEdit.AddListener( _ => {;