* in name when changing value
This commit is contained in:
parent
260f292947
commit
3919dfbedf
|
|
@ -105,11 +105,8 @@ namespace HeavenStudio.Editor
|
||||||
ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip));
|
ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip));
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log(action.parameters);
|
|
||||||
|
|
||||||
foreach (var p in action.parameters)
|
foreach (var p in action.parameters)
|
||||||
{
|
{
|
||||||
Debug.Log(p.collapseParams);
|
|
||||||
if (p.collapseParams == null || p.collapseParams.Count == 0) continue;
|
if (p.collapseParams == null || p.collapseParams.Count == 0) continue;
|
||||||
EventPropertyPrefab input = ePrefabs[p.propertyName].GetComponent<EventPropertyPrefab>();
|
EventPropertyPrefab input = ePrefabs[p.propertyName].GetComponent<EventPropertyPrefab>();
|
||||||
foreach (var c in p.collapseParams)
|
foreach (var c in p.collapseParams)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ namespace HeavenStudio.Editor
|
||||||
public class EventPropertyPrefab : MonoBehaviour
|
public class EventPropertyPrefab : MonoBehaviour
|
||||||
{
|
{
|
||||||
public TMP_Text caption;
|
public TMP_Text caption;
|
||||||
|
protected string _captionText;
|
||||||
public EventParameterManager parameterManager;
|
public EventParameterManager parameterManager;
|
||||||
public string propertyName;
|
public string propertyName;
|
||||||
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
||||||
|
|
@ -25,7 +26,10 @@ namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
this.parameterManager = EventParameterManager.instance;
|
this.parameterManager = EventParameterManager.instance;
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
this.caption.text = caption;
|
|
||||||
|
_captionText = caption;
|
||||||
|
|
||||||
|
this.caption.text = _captionText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateCollapse(object type)
|
public void UpdateCollapse(object type)
|
||||||
|
|
@ -34,7 +38,7 @@ namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
foreach (var c in p.collapseables)
|
foreach (var c in p.collapseables)
|
||||||
{
|
{
|
||||||
c.SetActive(p.collapseOn(type) && gameObject.activeSelf);
|
if (c != null) c.SetActive(p.collapseOn(type) && gameObject.activeSelf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,28 @@ namespace HeavenStudio.Editor
|
||||||
[Space(10)]
|
[Space(10)]
|
||||||
public Toggle toggle;
|
public Toggle toggle;
|
||||||
|
|
||||||
|
private bool _defaultValue;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
new public void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
InitProperties(propertyName, caption);
|
||||||
|
|
||||||
// ' (bool)type ' always results in false
|
_defaultValue = (bool)type;
|
||||||
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
|
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
|
||||||
|
|
||||||
toggle.onValueChanged.AddListener(
|
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);
|
UpdateCollapse(toggle.isOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,12 +21,26 @@ namespace HeavenStudio.Editor
|
||||||
public bool colorTableActive;
|
public bool colorTableActive;
|
||||||
public ColorPreview colorPreview;
|
public ColorPreview colorPreview;
|
||||||
|
|
||||||
|
private Color _defaultColor;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
new public void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
InitProperties(propertyName, caption);
|
||||||
|
|
||||||
colorPreview.colorPicker.onColorChanged += _ =>
|
colorPreview.colorPicker.onColorChanged += _ =>
|
||||||
|
{
|
||||||
parameterManager.entity[propertyName] = colorPreview.colorPicker.color;
|
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];
|
Color paramCol = parameterManager.entity[propertyName];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ namespace HeavenStudio.Editor
|
||||||
public TMP_Dropdown dropdown;
|
public TMP_Dropdown dropdown;
|
||||||
private Array enumVals;
|
private Array enumVals;
|
||||||
|
|
||||||
|
private int _defaultValue;
|
||||||
|
|
||||||
private bool openedDropdown = false;
|
private bool openedDropdown = false;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
new public void SetProperties(string propertyName, object type, string caption)
|
||||||
|
|
@ -28,6 +30,7 @@ namespace HeavenStudio.Editor
|
||||||
var enumType = type.GetType();
|
var enumType = type.GetType();
|
||||||
enumVals = Enum.GetValues(enumType);
|
enumVals = Enum.GetValues(enumType);
|
||||||
var enumNames = Enum.GetNames(enumType).ToList();
|
var enumNames = Enum.GetNames(enumType).ToList();
|
||||||
|
_defaultValue = (int)type;
|
||||||
|
|
||||||
// Can we assume non-holey enum?
|
// Can we assume non-holey enum?
|
||||||
// If we can we can simplify to dropdown.value = (int) parameterManager.entity[propertyName]
|
// If we can we can simplify to dropdown.value = (int) parameterManager.entity[propertyName]
|
||||||
|
|
@ -40,8 +43,18 @@ namespace HeavenStudio.Editor
|
||||||
dropdown.AddOptions(enumNames);
|
dropdown.AddOptions(enumNames);
|
||||||
dropdown.value = selected;
|
dropdown.value = selected;
|
||||||
|
|
||||||
dropdown.onValueChanged.AddListener(_ =>
|
dropdown.onValueChanged.AddListener(_ =>
|
||||||
parameterManager.entity[propertyName] = (int) enumVals.GetValue(dropdown.value)
|
{
|
||||||
|
parameterManager.entity[propertyName] = (int)enumVals.GetValue(dropdown.value);
|
||||||
|
if ((int)enumVals.GetValue(dropdown.value) != _defaultValue)
|
||||||
|
{
|
||||||
|
this.caption.text = _captionText + "*";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caption.text = _captionText;
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using Starpelly;
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
using HeavenStudio.Util;
|
||||||
using HeavenStudio.Editor;
|
using HeavenStudio.Editor;
|
||||||
|
using static HeavenStudio.EntityTypes;
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -19,6 +20,8 @@ namespace HeavenStudio.Editor
|
||||||
public Slider slider;
|
public Slider slider;
|
||||||
public TMP_InputField inputField;
|
public TMP_InputField inputField;
|
||||||
|
|
||||||
|
private float _defaultValue;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
new public void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
InitProperties(propertyName, caption);
|
||||||
|
|
@ -28,6 +31,7 @@ namespace HeavenStudio.Editor
|
||||||
case EntityTypes.Integer integer:
|
case EntityTypes.Integer integer:
|
||||||
slider.minValue = integer.min;
|
slider.minValue = integer.min;
|
||||||
slider.maxValue = integer.max;
|
slider.maxValue = integer.max;
|
||||||
|
_defaultValue = integer.val;
|
||||||
|
|
||||||
slider.wholeNumbers = true;
|
slider.wholeNumbers = true;
|
||||||
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
|
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
|
||||||
|
|
@ -38,6 +42,14 @@ namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
inputField.text = slider.value.ToString();
|
inputField.text = slider.value.ToString();
|
||||||
parameterManager.entity[propertyName] = (int) slider.value;
|
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);
|
slider.value = Convert.ToSingle(inputField.text);
|
||||||
parameterManager.entity[propertyName] = (int) slider.value;
|
parameterManager.entity[propertyName] = (int) slider.value;
|
||||||
Editor.instance.editingInputField = false;
|
Editor.instance.editingInputField = false;
|
||||||
|
if (slider.value != _defaultValue)
|
||||||
|
{
|
||||||
|
this.caption.text = _captionText + "*";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caption.text = _captionText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
@ -59,6 +79,7 @@ namespace HeavenStudio.Editor
|
||||||
case EntityTypes.Float fl:
|
case EntityTypes.Float fl:
|
||||||
slider.minValue = fl.min;
|
slider.minValue = fl.min;
|
||||||
slider.maxValue = fl.max;
|
slider.maxValue = fl.max;
|
||||||
|
_defaultValue = fl.val;
|
||||||
|
|
||||||
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
|
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
|
||||||
inputField.text = slider.value.ToString("G");
|
inputField.text = slider.value.ToString("G");
|
||||||
|
|
@ -69,6 +90,14 @@ namespace HeavenStudio.Editor
|
||||||
var newValue = (float) Math.Round(slider.value, 4);
|
var newValue = (float) Math.Round(slider.value, 4);
|
||||||
inputField.text = newValue.ToString("G");
|
inputField.text = newValue.ToString("G");
|
||||||
parameterManager.entity[propertyName] = newValue;
|
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);
|
slider.value = (float) Math.Round(Convert.ToSingle(inputField.text), 4);
|
||||||
parameterManager.entity[propertyName] = slider.value;
|
parameterManager.entity[propertyName] = slider.value;
|
||||||
Editor.instance.editingInputField = false;
|
Editor.instance.editingInputField = false;
|
||||||
|
if (slider.value != _defaultValue)
|
||||||
|
{
|
||||||
|
this.caption.text = "*" + _captionText;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caption.text = _captionText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using Starpelly;
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
using HeavenStudio.Util;
|
||||||
using HeavenStudio.Editor;
|
using HeavenStudio.Editor;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -18,10 +19,14 @@ namespace HeavenStudio.Editor
|
||||||
[Space(10)]
|
[Space(10)]
|
||||||
public TMP_InputField inputFieldString;
|
public TMP_InputField inputFieldString;
|
||||||
|
|
||||||
|
private string _defaultValue;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
new public void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
InitProperties(propertyName, caption);
|
||||||
|
|
||||||
|
_defaultValue = (string)type;
|
||||||
|
|
||||||
inputFieldString.text = (string) parameterManager.entity[propertyName];
|
inputFieldString.text = (string) parameterManager.entity[propertyName];
|
||||||
|
|
||||||
inputFieldString.onSelect.AddListener(
|
inputFieldString.onSelect.AddListener(
|
||||||
|
|
@ -30,10 +35,19 @@ namespace HeavenStudio.Editor
|
||||||
);
|
);
|
||||||
inputFieldString.onValueChanged.AddListener(
|
inputFieldString.onValueChanged.AddListener(
|
||||||
_ =>
|
_ =>
|
||||||
{;
|
{
|
||||||
parameterManager.entity[propertyName] = inputFieldString.text;
|
parameterManager.entity[propertyName] = inputFieldString.text;
|
||||||
|
if (inputFieldString.text != _defaultValue)
|
||||||
|
{
|
||||||
|
this.caption.text = _captionText + "*";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caption.text = _captionText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
inputFieldString.onEndEdit.AddListener(
|
inputFieldString.onEndEdit.AddListener(
|
||||||
_ =>
|
_ =>
|
||||||
{;
|
{;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue