about to make a struct + class, tooltip improvements
gonna make the struct define it, then the class will actually be the dropdown this is gonna make things so so so so much easier to comprehend
This commit is contained in:
parent
aeaad9dde0
commit
0054568364
|
|
@ -408,7 +408,6 @@ GameObject:
|
||||||
- component: {fileID: 1122443660375095479}
|
- component: {fileID: 1122443660375095479}
|
||||||
- component: {fileID: 1122443660375095465}
|
- component: {fileID: 1122443660375095465}
|
||||||
- component: {fileID: 1122443660375095464}
|
- component: {fileID: 1122443660375095464}
|
||||||
- component: {fileID: 6643933416157751036}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Text (TMP)
|
m_Name: Text (TMP)
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -464,7 +463,7 @@ MonoBehaviour:
|
||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: Karate Mannn
|
m_text: AWWWW :3 BWWWW
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: c2df694f599b22b42817910ff570a9df, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: c2df694f599b22b42817910ff570a9df, type: 2}
|
||||||
m_sharedMaterial: {fileID: -5829441969153149921, guid: c2df694f599b22b42817910ff570a9df, type: 2}
|
m_sharedMaterial: {fileID: -5829441969153149921, guid: c2df694f599b22b42817910ff570a9df, type: 2}
|
||||||
|
|
@ -476,12 +475,12 @@ MonoBehaviour:
|
||||||
rgba: 4281479730
|
rgba: 4281479730
|
||||||
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||||
m_enableVertexGradient: 0
|
m_enableVertexGradient: 0
|
||||||
m_colorMode: 3
|
m_colorMode: 0
|
||||||
m_fontColorGradient:
|
m_fontColorGradient:
|
||||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
topLeft: {r: 0.6792453, g: 0.061943684, b: 0.061943684, a: 1}
|
||||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
topRight: {r: 0.6792453, g: 0.061943684, b: 0.061943684, a: 1}
|
||||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
bottomLeft: {r: 0.6792453, g: 0.061943684, b: 0.061943684, a: 1}
|
||||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
bottomRight: {r: 0.6792453, g: 0.061943684, b: 0.061943684, a: 1}
|
||||||
m_fontColorGradientPreset: {fileID: 0}
|
m_fontColorGradientPreset: {fileID: 0}
|
||||||
m_spriteAsset: {fileID: 0}
|
m_spriteAsset: {fileID: 0}
|
||||||
m_tintAllSprites: 0
|
m_tintAllSprites: 0
|
||||||
|
|
@ -535,29 +534,3 @@ MonoBehaviour:
|
||||||
m_hasFontAssetChanged: 0
|
m_hasFontAssetChanged: 0
|
||||||
m_baseMaterial: {fileID: 0}
|
m_baseMaterial: {fileID: 0}
|
||||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||||
--- !u!114 &6643933416157751036
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1122443660375095478}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Padding:
|
|
||||||
m_Left: 0
|
|
||||||
m_Right: 0
|
|
||||||
m_Top: 0
|
|
||||||
m_Bottom: 0
|
|
||||||
m_ChildAlignment: 4
|
|
||||||
m_Spacing: 0
|
|
||||||
m_ChildForceExpandWidth: 1
|
|
||||||
m_ChildForceExpandHeight: 1
|
|
||||||
m_ChildControlWidth: 1
|
|
||||||
m_ChildControlHeight: 0
|
|
||||||
m_ChildScaleWidth: 1
|
|
||||||
m_ChildScaleHeight: 0
|
|
||||||
m_ReverseArrangement: 0
|
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ MonoBehaviour:
|
||||||
m_linkedTextComponent: {fileID: 0}
|
m_linkedTextComponent: {fileID: 0}
|
||||||
parentLinkedComponent: {fileID: 0}
|
parentLinkedComponent: {fileID: 0}
|
||||||
m_enableKerning: 1
|
m_enableKerning: 1
|
||||||
m_ActiveFontFeatures: 00000000
|
m_ActiveFontFeatures: 6e72656b
|
||||||
m_enableExtraPadding: 0
|
m_enableExtraPadding: 0
|
||||||
checkPaddingRequired: 0
|
checkPaddingRequired: 0
|
||||||
m_isRichText: 1
|
m_isRichText: 1
|
||||||
|
|
@ -298,7 +298,7 @@ MonoBehaviour:
|
||||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
m_isUsingLegacyAnimationComponent: 0
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
m_isVolumetricText: 0
|
m_isVolumetricText: 0
|
||||||
m_hasFontAssetChanged: 1
|
m_hasFontAssetChanged: 0
|
||||||
m_baseMaterial: {fileID: 0}
|
m_baseMaterial: {fileID: 0}
|
||||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||||
--- !u!1 &2779900776966339891
|
--- !u!1 &2779900776966339891
|
||||||
|
|
@ -489,7 +489,7 @@ RectTransform:
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 1}
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
m_SizeDelta: {x: 143, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &2779900777028293775
|
--- !u!222 &2779900777028293775
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
|
@ -658,7 +658,7 @@ Canvas:
|
||||||
m_OverrideSorting: 1
|
m_OverrideSorting: 1
|
||||||
m_OverridePixelPerfect: 0
|
m_OverridePixelPerfect: 0
|
||||||
m_SortingBucketNormalizedSize: 0
|
m_SortingBucketNormalizedSize: 0
|
||||||
m_AdditionalShaderChannelsFlag: 0
|
m_AdditionalShaderChannelsFlag: 25
|
||||||
m_SortingLayerID: 610346305
|
m_SortingLayerID: 610346305
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_TargetDisplay: 0
|
m_TargetDisplay: 0
|
||||||
|
|
@ -921,7 +921,7 @@ RectTransform:
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 2779900777667040950}
|
m_GameObject: {fileID: 2779900777667040950}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
|
|
@ -1441,7 +1441,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!224 &6474185410112721790
|
--- !u!224 &6474185410112721790
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -131,30 +131,42 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
private GameObject AddParam(string propertyName, object type, string caption, string tooltip = "")
|
private GameObject AddParam(string propertyName, object type, string caption, string tooltip = "")
|
||||||
{
|
{
|
||||||
if (!PropertyPrefabs.TryGetValue(type.GetType(), out GameObject propertyPrefab)) {
|
Type typeType = type.GetType();
|
||||||
Debug.LogError("Can't make property interface of type: " + type.GetType());
|
GameObject propertyPrefab = DropdownP; // enum check is hardcoded because enums are awesome (lying)
|
||||||
|
if (!typeType.IsEnum && !PropertyPrefabs.TryGetValue(typeType, out propertyPrefab)) {
|
||||||
|
Debug.LogError("Can't make property interface of type: " + typeType);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
print(propertyPrefab.name);
|
||||||
|
|
||||||
GameObject input = InitPrefab(propertyPrefab, tooltip);
|
GameObject input = Instantiate(propertyPrefab);
|
||||||
|
input.transform.SetParent(this.gameObject.transform);
|
||||||
|
input.SetActive(true);
|
||||||
|
input.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
if (tooltip != string.Empty) {
|
||||||
|
Tooltip.AddTooltip(input, tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
EventPropertyPrefab property = input.GetComponent<EventPropertyPrefab>();
|
EventPropertyPrefab property = input.GetComponent<EventPropertyPrefab>();
|
||||||
property.SetProperties(propertyName, type, caption);
|
property.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameObject InitPrefab(GameObject prefab, string tooltip = "")
|
// private GameObject InitPrefab(GameObject prefab, string tooltip = "")
|
||||||
{
|
// {
|
||||||
GameObject input = Instantiate(prefab);
|
// GameObject input = Instantiate(prefab);
|
||||||
input.transform.SetParent(this.gameObject.transform);
|
// input.transform.SetParent(this.gameObject.transform);
|
||||||
input.SetActive(true);
|
// input.SetActive(true);
|
||||||
input.transform.localScale = Vector3.one;
|
// input.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
if(tooltip != string.Empty)
|
// if (tooltip != string.Empty) {
|
||||||
Tooltip.AddTooltip(input, "", tooltip);
|
// Tooltip.AddTooltip(input, "", tooltip);
|
||||||
|
// }
|
||||||
|
|
||||||
return input;
|
// return input;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void DestroyParams()
|
private void DestroyParams()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,17 +15,17 @@ namespace HeavenStudio.Editor
|
||||||
public TMP_Text caption;
|
public TMP_Text caption;
|
||||||
protected string _captionText;
|
protected string _captionText;
|
||||||
public EventParameterManager parameterManager;
|
public EventParameterManager parameterManager;
|
||||||
|
public RiqEntity entity;
|
||||||
public string propertyName;
|
public string propertyName;
|
||||||
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
||||||
|
|
||||||
public virtual void SetProperties(string propertyName, object type, string caption)
|
public virtual void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
this.parameterManager = EventParameterManager.instance;
|
this.parameterManager = EventParameterManager.instance;
|
||||||
|
|
||||||
|
entity = parameterManager.entity;
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
|
this.caption.text = _captionText = caption;
|
||||||
_captionText = caption;
|
|
||||||
|
|
||||||
this.caption.text = _captionText;
|
|
||||||
}
|
}
|
||||||
public virtual void SetCollapses(object type) { }
|
public virtual void SetCollapses(object type) { }
|
||||||
|
|
||||||
|
|
@ -33,9 +33,12 @@ namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
foreach (var p in propertyCollapses)
|
foreach (var p in propertyCollapses)
|
||||||
{
|
{
|
||||||
foreach (var c in p.collapseables)
|
if (p.collapseables.Count > 0) { // there could be a better way to do it, but for now this works
|
||||||
{
|
foreach (var c in p.collapseables) {
|
||||||
if (c != null) c.SetActive(p.collapseOn(type, p.entity) && gameObject.activeSelf);
|
if (c != null) c.SetActive(p.collapseOn(type, p.entity) && gameObject.activeSelf);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_ = p.collapseOn(type, p.entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,22 +21,13 @@ namespace HeavenStudio.Editor
|
||||||
base.SetProperties(propertyName, type, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
_defaultValue = (bool)type;
|
_defaultValue = (bool)type;
|
||||||
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
|
toggle.isOn = Convert.ToBoolean(entity[propertyName]);
|
||||||
|
|
||||||
toggle.onValueChanged.AddListener(
|
toggle.onValueChanged.AddListener(_ =>
|
||||||
_ =>
|
{
|
||||||
{
|
entity[propertyName] = toggle.isOn;
|
||||||
parameterManager.entity[propertyName] = toggle.isOn;
|
this.caption.text = (toggle.isOn != _defaultValue) ? (_captionText + "*") : _captionText;
|
||||||
if (toggle.isOn != _defaultValue)
|
});
|
||||||
{
|
|
||||||
this.caption.text = _captionText + "*";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.caption.text = _captionText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetValue()
|
public void ResetValue()
|
||||||
|
|
@ -46,9 +37,7 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
public override void SetCollapses(object type)
|
public override void SetCollapses(object type)
|
||||||
{
|
{
|
||||||
toggle.onValueChanged.AddListener(
|
toggle.onValueChanged.AddListener(newVal => UpdateCollapse(newVal));
|
||||||
_ => UpdateCollapse(toggle.isOn)
|
|
||||||
);
|
|
||||||
UpdateCollapse(toggle.isOn);
|
UpdateCollapse(toggle.isOn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using UnityEngine;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using Jukebox;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -16,16 +11,14 @@ namespace HeavenStudio.Editor
|
||||||
// public Button buttonObj;
|
// public Button buttonObj;
|
||||||
public TMP_Text buttonText;
|
public TMP_Text buttonText;
|
||||||
public EntityTypes.Button button;
|
public EntityTypes.Button button;
|
||||||
public RiqEntity entity;
|
|
||||||
|
|
||||||
public override void SetProperties(string propertyName, object type, string caption)
|
public override void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
base.SetProperties(propertyName, type, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
entity = parameterManager.entity;
|
|
||||||
|
|
||||||
if (type is EntityTypes.Button button) {
|
if (type is EntityTypes.Button button) {
|
||||||
this.button = button;
|
this.button = button;
|
||||||
buttonText.text = button.defaultLabel;
|
buttonText.text = entity[propertyName];
|
||||||
} else {
|
} else {
|
||||||
Debug.LogError("ButtonPropertyPrefab was unable to use " + type.GetType() + " as a Button.");
|
Debug.LogError("ButtonPropertyPrefab was unable to use " + type.GetType() + " as a Button.");
|
||||||
return;
|
return;
|
||||||
|
|
@ -36,8 +29,17 @@ namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
string text = button.onClick.Invoke(entity);
|
string text = button.onClick.Invoke(entity);
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
buttonText.text = text;
|
buttonText.text = entity[propertyName] = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OnClick() already handles this.
|
||||||
|
// if somebody wants to uncomment this for their thing feel free but it's unused for now -AJ
|
||||||
|
// private void LateUpdate()
|
||||||
|
// {
|
||||||
|
// if (entity[propertyName] != buttonText.text) {
|
||||||
|
// buttonText.text = entity[propertyName];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -17,7 +17,6 @@ namespace HeavenStudio.Editor
|
||||||
[Header("Dropdown")]
|
[Header("Dropdown")]
|
||||||
[Space(10)]
|
[Space(10)]
|
||||||
public LeftClickTMP_Dropdown dropdown;
|
public LeftClickTMP_Dropdown dropdown;
|
||||||
private List<int> keys;
|
|
||||||
|
|
||||||
private int _defaultValue;
|
private int _defaultValue;
|
||||||
|
|
||||||
|
|
@ -27,52 +26,41 @@ namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
base.SetProperties(propertyName, type, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
// var enumType = type.GetType();
|
|
||||||
// values = Enum.GetValues(enumType).Cast<string>().ToArray();
|
|
||||||
// names = 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]
|
|
||||||
// var currentlySelected = (int)parameterManager.entity[propertyName];
|
|
||||||
RiqEntity entity = parameterManager.entity;
|
RiqEntity entity = parameterManager.entity;
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case EntityTypes.Dropdown dropdownEntity:
|
case EntityTypes.Dropdown dropdownEntity:
|
||||||
entity[propertyName].values = dropdownEntity.values;
|
// entity[propertyName].ChangeValues(dropdownEntity.Values);
|
||||||
selected = dropdownEntity.defaultValue;
|
selected = entity[propertyName].currentIndex;
|
||||||
|
if (dropdownEntity.Values != null) dropdown.AddOptions(entity[propertyName].Values);
|
||||||
|
dropdown.onValueChanged.AddListener(newVal => parameterManager.entity[propertyName].currentIndex = newVal);
|
||||||
|
entity[propertyName].onValueChanged = new Action<List<string>>(newValues =>
|
||||||
|
{
|
||||||
|
if (dropdown == null) return;
|
||||||
|
dropdown.ClearOptions();
|
||||||
|
dropdown.AddOptions(newValues);
|
||||||
|
dropdown.enabled = newValues.Count > 0;
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case Enum enumEntity:
|
case Enum enumEntity:
|
||||||
var enumType = enumEntity.GetType();
|
Type enumType = enumEntity.GetType();
|
||||||
entity[propertyName] = Enum.GetNames(enumType).ToList();
|
int[] keys = Enum.GetValues(enumType).Cast<int>().ToArray();
|
||||||
keys = Enum.GetValues(enumType).Cast<int>().ToList();
|
selected = Array.FindIndex(keys, val => val == (int)entity[propertyName]);
|
||||||
for (int i = 0; i < keys.Count; i++) {
|
|
||||||
print("key " + (i + 1) + " : " + keys[i]);
|
dropdown.AddOptions(Enum.GetNames(enumType).ToList());
|
||||||
}
|
dropdown.onValueChanged.AddListener(val => parameterManager.entity[propertyName] = keys[val]);
|
||||||
selected = keys.FindIndex(val => val == (int)entity[propertyName]);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dropdown.AddOptions(entity[propertyName].values);
|
|
||||||
dropdown.value = selected;
|
dropdown.value = selected;
|
||||||
|
dropdown.enabled = dropdown.options.Count > 0;
|
||||||
|
|
||||||
entity[propertyName].valueChanged = new Action<List<string>>(newValues =>
|
dropdown.onValueChanged.AddListener(newValue => {
|
||||||
{
|
this.caption.text = (newValue != _defaultValue) ? (_captionText + "*") : _captionText;
|
||||||
print(string.Join(", ", entity[propertyName].values));
|
|
||||||
dropdown.ClearOptions();
|
|
||||||
dropdown.AddOptions(newValues);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dropdown.onValueChanged.AddListener(newValue =>
|
|
||||||
{
|
|
||||||
parameterManager.entity[propertyName].currentIndex = newValue;
|
|
||||||
Debug.Log("newValue : " + newValue);
|
|
||||||
this.caption.text = (newValue != _defaultValue) ? (_captionText + "*") : _captionText;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetValue()
|
public void ResetValue()
|
||||||
|
|
|
||||||
|
|
@ -144,23 +144,10 @@ namespace HeavenStudio.Editor
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EntityTypes.Float fl:
|
case EntityTypes.Float fl:
|
||||||
slider.onValueChanged.AddListener(
|
slider.onValueChanged.AddListener(newVal => UpdateCollapse((float)Math.Round(newVal, 4)));
|
||||||
_ =>
|
inputField.onEndEdit.AddListener(_ => UpdateCollapse(slider.value));
|
||||||
{
|
|
||||||
var newValue = (float)Math.Round(slider.value, 4);
|
|
||||||
UpdateCollapse(newValue);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
var newValue = (float)Math.Round(slider.value, 4);
|
UpdateCollapse((float)Math.Round(slider.value, 4));
|
||||||
UpdateCollapse(newValue);
|
|
||||||
|
|
||||||
inputField.onEndEdit.AddListener(
|
|
||||||
_ =>
|
|
||||||
{
|
|
||||||
UpdateCollapse(slider.value);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
_defaultValue = (string)type;
|
_defaultValue = (string)type;
|
||||||
|
|
||||||
inputFieldString.text = (string) parameterManager.entity[propertyName];
|
inputFieldString.text = (string)entity[propertyName];
|
||||||
|
|
||||||
inputFieldString.onSelect.AddListener(
|
inputFieldString.onSelect.AddListener(
|
||||||
_ =>
|
_ =>
|
||||||
|
|
@ -36,15 +36,8 @@ namespace HeavenStudio.Editor
|
||||||
inputFieldString.onValueChanged.AddListener(
|
inputFieldString.onValueChanged.AddListener(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
parameterManager.entity[propertyName] = inputFieldString.text;
|
entity[propertyName] = inputFieldString.text;
|
||||||
if (inputFieldString.text != _defaultValue)
|
this.caption.text = (inputFieldString.text != _defaultValue) ? (_captionText + "*") : _captionText;
|
||||||
{
|
|
||||||
this.caption.text = _captionText + "*";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.caption.text = _captionText;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -63,16 +56,15 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
public override void SetCollapses(object type)
|
public override void SetCollapses(object type)
|
||||||
{
|
{
|
||||||
inputFieldString.onValueChanged.AddListener(
|
inputFieldString.onValueChanged.AddListener(newVal => UpdateCollapse(newVal));
|
||||||
_ =>
|
|
||||||
{
|
|
||||||
UpdateCollapse(inputFieldString.text);
|
|
||||||
});
|
|
||||||
UpdateCollapse(inputFieldString.text);
|
UpdateCollapse(inputFieldString.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void LateUpdate()
|
||||||
{
|
{
|
||||||
|
if (entity[propertyName] != inputFieldString.text) {
|
||||||
|
inputFieldString.text =entity[propertyName];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -898,6 +898,10 @@ namespace HeavenStudio.Editor.Track
|
||||||
{
|
{
|
||||||
returnVal = floatVal.val;
|
returnVal = floatVal.val;
|
||||||
}
|
}
|
||||||
|
else if (returnVal is EntityTypes.Button buttonVal)
|
||||||
|
{
|
||||||
|
returnVal = buttonVal.label;
|
||||||
|
}
|
||||||
else if (returnVal.GetType().IsEnum)
|
else if (returnVal.GetType().IsEnum)
|
||||||
{
|
{
|
||||||
returnVal = (int)ep[i].parameter;
|
returnVal = (int)ep[i].parameter;
|
||||||
|
|
|
||||||
|
|
@ -388,12 +388,10 @@ namespace HeavenStudio.Editor.Track
|
||||||
}
|
}
|
||||||
else if (Input.GetMouseButton(2))
|
else if (Input.GetMouseButton(2))
|
||||||
{
|
{
|
||||||
// var mgs = EventCaller.instance.minigames;
|
|
||||||
string[] datamodels = entity.datamodel.Split('/');
|
string[] datamodels = entity.datamodel.Split('/');
|
||||||
Debug.Log("Selected entity's datamodel : " + entity.datamodel);
|
Debug.Log("Selected entity's datamodel : " + entity.datamodel);
|
||||||
|
|
||||||
bool isSwitchGame = datamodels[1] == "switchGame";
|
bool isSwitchGame = datamodels[1] == "switchGame";
|
||||||
// int gameIndex = mgs.FindIndex(c => c.name == datamodels[isSwitchGame ? 2 : 0]);
|
|
||||||
int block = isSwitchGame ? 0 : EventCaller.instance.minigames[datamodels[isSwitchGame ? 2 : 0]].actions.FindIndex(c => c.actionName == datamodels[1]) + 1;
|
int block = isSwitchGame ? 0 : EventCaller.instance.minigames[datamodels[isSwitchGame ? 2 : 0]].actions.FindIndex(c => c.actionName == datamodels[1]) + 1;
|
||||||
|
|
||||||
if (!isSwitchGame)
|
if (!isSwitchGame)
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,15 @@ namespace HeavenStudio.Editor
|
||||||
private void OnEnterPrivate(string tooltipText, string altTooltipText)
|
private void OnEnterPrivate(string tooltipText, string altTooltipText)
|
||||||
{
|
{
|
||||||
group.alpha = 1;
|
group.alpha = 1;
|
||||||
SetText(tooltipText);
|
|
||||||
Editor.instance.tooltipText.text = altTooltipText.Replace("\n","");
|
text.text = tooltipText;
|
||||||
|
text.ForceMeshUpdate();
|
||||||
|
|
||||||
|
Vector2 textSize = text.GetRenderedValues(false);
|
||||||
|
Vector2 paddingSize = new Vector2(8, 8);
|
||||||
|
|
||||||
|
background.sizeDelta = textSize + paddingSize;
|
||||||
|
Editor.instance.tooltipText.text = altTooltipText.Replace("\n", "");
|
||||||
Editor.instance.tooltipText.ForceMeshUpdate();
|
Editor.instance.tooltipText.ForceMeshUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,10 +99,9 @@ namespace HeavenStudio.Editor
|
||||||
background.sizeDelta = textSize + paddingSize;
|
background.sizeDelta = textSize + paddingSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddTooltip(GameObject g, string tooltipText, string altTooltipText = "")
|
public static void AddTooltip(GameObject g, string tooltipText, string altTooltipText = null)
|
||||||
{
|
{
|
||||||
if (altTooltipText == "")
|
altTooltipText ??= tooltipText;
|
||||||
altTooltipText = tooltipText;
|
|
||||||
|
|
||||||
EventTrigger et = g.AddComponent<EventTrigger>();
|
EventTrigger et = g.AddComponent<EventTrigger>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -699,7 +699,7 @@ namespace HeavenStudio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="collapseOn">What values should make it collapse/uncollapse?</param>
|
/// <param name="collapseOn">What values should make it collapse/uncollapse?</param>
|
||||||
/// <param name="collapseables">IDs of the parameters to collapse</param>
|
/// <param name="collapseables">IDs of the parameters to collapse</param>
|
||||||
public CollapseParam(Func<object, RiqEntity, bool> collapseOn, string[] collapseables)
|
public CollapseParam(Func<object, RiqEntity, bool> collapseOn, params string[] collapseables)
|
||||||
{
|
{
|
||||||
CollapseOn = collapseOn;
|
CollapseOn = collapseOn;
|
||||||
this.collapseables = collapseables;
|
this.collapseables = collapseables;
|
||||||
|
|
@ -1163,20 +1163,9 @@ namespace HeavenStudio
|
||||||
Minigame game = gm.GetGameInfo(gm.currentGame);
|
Minigame game = gm.GetGameInfo(gm.currentGame);
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
var animators = gm.minigameObj.transform.GetComponentsInChildren<Animator>();
|
var animators = gm.minigameObj.transform.GetComponentsInChildren<Animator>();
|
||||||
// e["animator"] = string.Join(", ", animators.Select(anim => {
|
// not in an update loop so it's fine :3
|
||||||
// var obj = anim.gameObject;
|
|
||||||
// // string path = "/" + obj.name;
|
|
||||||
// List<string> path = new() { obj.name };
|
|
||||||
// while (obj.transform.parent != null && obj.transform.parent.name != game.name)
|
|
||||||
// {
|
|
||||||
// obj = obj.transform.parent.gameObject;
|
|
||||||
// path.Add(obj.name);
|
|
||||||
// }
|
|
||||||
// return string.Join('/', path);
|
|
||||||
// }));
|
|
||||||
e["animator"].ChangeValues(animators.Select(anim => {
|
e["animator"].ChangeValues(animators.Select(anim => {
|
||||||
var obj = anim.gameObject;
|
var obj = anim.gameObject;
|
||||||
// string path = "/" + obj.name;
|
|
||||||
List<string> path = new() { obj.name };
|
List<string> path = new() { obj.name };
|
||||||
while (obj.transform.parent != null && obj.transform.parent.name != game.name)
|
while (obj.transform.parent != null && obj.transform.parent.name != game.name)
|
||||||
{
|
{
|
||||||
|
|
@ -1188,36 +1177,46 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
return game?.displayName ?? "No Game";
|
return game?.displayName ?? "No Game";
|
||||||
}), "Get Animators", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"),
|
}), "Get Animators", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"),
|
||||||
new Param("animator", new EntityTypes.Dropdown(0, "N/A"), "Animator", "Specify which animator in the scene to play an animation on."),
|
new Param("animator", new EntityTypes.Dropdown(), "Animator", "Specify which animator in the scene to play an animation on."),
|
||||||
new Param("getAnimations", new EntityTypes.Button("N/A", e => {
|
new Param("getAnimations", new EntityTypes.Button("", e => {
|
||||||
var gm = GameManager.instance;
|
var gm = GameManager.instance;
|
||||||
Minigame game = gm.GetGameInfo(gm.currentGame);
|
Minigame game = gm.GetGameInfo(gm.currentGame);
|
||||||
var animObj = gm.minigameObj.transform.Find(((EntityTypes.Dropdown)e["animator"]).currentValue);
|
string animPath = e["animator"].CurrentValue;
|
||||||
Animator animator = null;
|
Animator animator = null;
|
||||||
if (animObj != null && animObj.TryGetComponent(out animator) && animator != null) {
|
if (animPath != null) {
|
||||||
e["animation"].ChangeValues(animator.runtimeAnimatorController.animationClips.Select(x => x.name).ToList());
|
var animObj = gm.minigameObj.transform.Find(animPath);
|
||||||
|
if (animObj != null && animObj.TryGetComponent(out animator) && animator != null) {
|
||||||
|
var animations = animator.runtimeAnimatorController.animationClips.Select(x => x.name).ToList();
|
||||||
|
e["animation"].ChangeValues(animations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return animator != null ? animator.name : "N/A";
|
return animator != null ? animator.name : "N/A";
|
||||||
}), "Get Animations", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"),
|
}), "Get Animations", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"),
|
||||||
new Param("animation", new EntityTypes.Dropdown(0, "N/A"), "Animation", "Specify the name of the animation to play."),
|
new Param("animation", new EntityTypes.Dropdown(), "Animation", "Specify the name of the animation to play."),
|
||||||
new Param("scale", new EntityTypes.Float(0, 5, 0.5f), "Animation Scale", "The time scale of the animation. Higher values are faster."),
|
new Param("scale", new EntityTypes.Float(0, 5, 0.5f), "Animation Scale", "The time scale of the animation. Higher values are faster."),
|
||||||
},
|
},
|
||||||
delegate {
|
delegate {
|
||||||
var e = eventCaller.currentEntity;
|
var e = eventCaller.currentEntity;
|
||||||
GameManager.instance.PlayAnimationArbitrary(e["animator"].currentValue, e["animation"].currentValue, e["scale"]);
|
GameManager.instance.PlayAnimationArbitrary(e["animator"].CurrentValue, e["animation"].CurrentValue, e["scale"]);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
new GameAction("play sfx", "Play SFX", 0.5f, false,
|
new GameAction("play sfx", "Play SFX", 0.5f, false,
|
||||||
new List<Param>()
|
new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("game", new EntityTypes.Dropdown(0, EventCaller.instance.minigames.Values.Select(x => x.displayName).ToArray()), "Which Game", "Specify the game's sfx to play. An empty input will play global sfx."),
|
new Param("game", new EntityTypes.Dropdown(0), "Which Game", "Specify the game's sfx to play. An empty input will play global sfx.", new() {
|
||||||
|
new((x, e) => {
|
||||||
|
e["game"].ChangeValues(EventCaller.instance.minigames.Values.Select(x => x.displayName).ToList());
|
||||||
|
return true;
|
||||||
|
}),
|
||||||
|
}),
|
||||||
new Param("sfxName", "", "SFX Name", "The name of the sfx to play."),
|
new Param("sfxName", "", "SFX Name", "The name of the sfx to play."),
|
||||||
new Param("pitch", new EntityTypes.Float(0, 5, 1), "Pitch", "The sfx's pitch."),
|
new Param("pitch", new EntityTypes.Float(0, 5, 1), "Pitch", "The sfx's pitch."),
|
||||||
new Param("offset", new EntityTypes.Float(-500, 500), "Offset (ms)", "The sfx's offset in milliseconds."),
|
new Param("offset", new EntityTypes.Float(-500, 500), "Offset (ms)", "The sfx's offset in milliseconds."),
|
||||||
},
|
},
|
||||||
preFunction : delegate {
|
preFunction : delegate {
|
||||||
var e = eventCaller.currentEntity;
|
var e = eventCaller.currentEntity;
|
||||||
GameManager.PlaySFXArbitrary(e.beat, e["game"], e["sfxName"], e["pitch"], e["offset"]);
|
var mgs = EventCaller.instance.minigames.Values;
|
||||||
|
GameManager.PlaySFXArbitrary(e.beat, mgs.ElementAt((int)e["game"].currentIndex).name, e["sfxName"], e["pitch"], e["offset"]);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jukebox;
|
using Jukebox;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace HeavenStudio
|
namespace HeavenStudio
|
||||||
|
|
@ -65,12 +64,12 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public struct Button
|
public struct Button
|
||||||
{
|
{
|
||||||
public string defaultLabel;
|
public string label;
|
||||||
public Func<RiqEntity, string> onClick;
|
public Func<RiqEntity, string> onClick;
|
||||||
|
|
||||||
public Button(string defaultLabel, Func<RiqEntity, string> onClick)
|
public Button(string defaultLabel, Func<RiqEntity, string> onClick)
|
||||||
{
|
{
|
||||||
this.defaultLabel = defaultLabel;
|
this.label = defaultLabel;
|
||||||
this.onClick = onClick;
|
this.onClick = onClick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,21 +78,22 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
public void ChangeValues(List<string> values)
|
public void ChangeValues(List<string> values)
|
||||||
{
|
{
|
||||||
this.values = values;
|
this.Values = values ?? new();
|
||||||
valueChanged?.Invoke(values);
|
onValueChanged?.Invoke(values);
|
||||||
}
|
}
|
||||||
public int defaultValue;
|
public int defaultValue;
|
||||||
public List<string> values;
|
public List<string> Values { get; private set; }
|
||||||
public int currentIndex;
|
public int currentIndex;
|
||||||
public readonly string currentValue => values[currentIndex];
|
public readonly string CurrentValue => currentIndex < Values?.Count - 1 ? Values?[currentIndex] : null;
|
||||||
public Action<List<string>> valueChanged;
|
[JsonIgnore] public Action<List<string>> onValueChanged;
|
||||||
|
|
||||||
public Dropdown(int defaultValue, params string[] values)
|
public Dropdown(int defaultValue = 0, params string[] values)
|
||||||
{
|
{
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
this.values = values.ToList();
|
this.Values = values.ToList();
|
||||||
|
|
||||||
currentIndex = 0;
|
currentIndex = 0;
|
||||||
valueChanged = null;
|
onValueChanged = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue