things are very nearly working!
however i just hit an insane hurdle. how do i modify a dropdown while still being able to access the index/int value of that param directly. UGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
This commit is contained in:
parent
e073d83e30
commit
9fb8b22824
|
|
@ -55,6 +55,7 @@ MonoBehaviour:
|
||||||
caption: {fileID: 161819469598736649}
|
caption: {fileID: 161819469598736649}
|
||||||
parameterManager: {fileID: 0}
|
parameterManager: {fileID: 0}
|
||||||
propertyName:
|
propertyName:
|
||||||
|
buttonText: {fileID: 1122443660375095464}
|
||||||
--- !u!114 &1492239408036616687
|
--- !u!114 &1492239408036616687
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,7 @@ RectTransform:
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 10, y: 0}
|
m_SizeDelta: {x: 10, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
|
@ -885,7 +885,7 @@ RectTransform:
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 20, y: 0}
|
m_SizeDelta: {x: 20, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
|
@ -943,7 +943,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 &872153477128913844
|
--- !u!224 &872153477128913844
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -13012,7 +13012,7 @@ MonoBehaviour:
|
||||||
m_TargetGraphic: {fileID: 171581557}
|
m_TargetGraphic: {fileID: 171581557}
|
||||||
m_HandleRect: {fileID: 171581556}
|
m_HandleRect: {fileID: 171581556}
|
||||||
m_Direction: 2
|
m_Direction: 2
|
||||||
m_Value: 1
|
m_Value: 0
|
||||||
m_Size: 1
|
m_Size: 1
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
|
|
@ -24624,7 +24624,7 @@ MonoBehaviour:
|
||||||
m_HandleRect: {fileID: 1589389271}
|
m_HandleRect: {fileID: 1589389271}
|
||||||
m_Direction: 2
|
m_Direction: 2
|
||||||
m_Value: 1
|
m_Value: 1
|
||||||
m_Size: 0.44222867
|
m_Size: 1
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|
@ -30367,7 +30367,7 @@ RectTransform:
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0.5}
|
m_AnchorMin: {x: 0, y: 0.5}
|
||||||
m_AnchorMax: {x: 1, y: 0.5}
|
m_AnchorMax: {x: 1, y: 0.5}
|
||||||
m_AnchoredPosition: {x: 0, y: 186.98236}
|
m_AnchoredPosition: {x: 0, y: 121.30615}
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 1}
|
m_Pivot: {x: 0.5, y: 1}
|
||||||
--- !u!222 &1154875945
|
--- !u!222 &1154875945
|
||||||
|
|
@ -39827,8 +39827,8 @@ MonoBehaviour:
|
||||||
m_TargetGraphic: {fileID: 1220118245}
|
m_TargetGraphic: {fileID: 1220118245}
|
||||||
m_HandleRect: {fileID: 1220118244}
|
m_HandleRect: {fileID: 1220118244}
|
||||||
m_Direction: 2
|
m_Direction: 2
|
||||||
m_Value: 1
|
m_Value: 1.0000005
|
||||||
m_Size: 1
|
m_Size: 0.60682213
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace HeavenStudio
|
||||||
public string currentGame { get; private set; }
|
public string currentGame { get; private set; }
|
||||||
public GameObject minigameObj { get; private set; }
|
public GameObject minigameObj { get; private set; }
|
||||||
public Minigame minigame { get; private set; }
|
public Minigame minigame { get; private set; }
|
||||||
public Animator[] mgAnimators { get; private set; }
|
public Animator[] minigameAnimators { get; set; }
|
||||||
public RiqEntity lastSection { get; private set; }
|
public RiqEntity lastSection { get; private set; }
|
||||||
public RiqEntity currentSection { get; private set; }
|
public RiqEntity currentSection { get; private set; }
|
||||||
|
|
||||||
|
|
@ -631,13 +631,9 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayAnimationArbitrary(string animator, string animation, float scale)
|
public void PlayAnimationArbitrary(int animator, int animation, float scale)
|
||||||
{
|
{
|
||||||
// if possible (efficient enough) id like to find the object recursively, but for now this works
|
|
||||||
Transform animTrans = minigameObj.transform.Find(animator);
|
|
||||||
if (animTrans != null && animTrans.TryGetComponent<Animator>(out var anim)) {
|
|
||||||
anim.DoScaledAnimationAsync(animation, scale);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleInputs(bool inputs)
|
public void ToggleInputs(bool inputs)
|
||||||
|
|
@ -1142,7 +1138,6 @@ namespace HeavenStudio
|
||||||
minigameObj.transform.parent = eventCaller.GamesHolder.transform;
|
minigameObj.transform.parent = eventCaller.GamesHolder.transform;
|
||||||
minigameObj.transform.localScale = originalScale;
|
minigameObj.transform.localScale = originalScale;
|
||||||
minigameObj.name = game;
|
minigameObj.name = game;
|
||||||
mgAnimators = minigameObj.transform.GetComponentsInChildren<Animator>();
|
|
||||||
|
|
||||||
SetCurrentGame(game, useMinigameColor);
|
SetCurrentGame(game, useMinigameColor);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,10 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
using HeavenStudio.Editor.Track;
|
|
||||||
using Jukebox;
|
using Jukebox;
|
||||||
using Jukebox.Legacy;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms.VisualStyles;
|
using static HeavenStudio.EntityTypes;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -26,6 +23,7 @@ namespace HeavenStudio.Editor
|
||||||
[SerializeField] private GameObject DropdownP;
|
[SerializeField] private GameObject DropdownP;
|
||||||
[SerializeField] private GameObject ColorP;
|
[SerializeField] private GameObject ColorP;
|
||||||
[SerializeField] private GameObject StringP;
|
[SerializeField] private GameObject StringP;
|
||||||
|
private static Dictionary<Type, GameObject> PropertyPrefabs;
|
||||||
|
|
||||||
public RiqEntity entity;
|
public RiqEntity entity;
|
||||||
|
|
||||||
|
|
@ -40,6 +38,18 @@ namespace HeavenStudio.Editor
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
if (PropertyPrefabs == null) {
|
||||||
|
PropertyPrefabs = new() {
|
||||||
|
{ typeof(Integer), IntegerP },
|
||||||
|
{ typeof(Float), FloatP },
|
||||||
|
{ typeof(Dropdown), DropdownP },
|
||||||
|
{ typeof(Button), ButtonP },
|
||||||
|
{ typeof(Color), ColorP },
|
||||||
|
{ typeof(bool), BooleanP },
|
||||||
|
{ typeof(string), StringP },
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
|
|
@ -74,15 +84,6 @@ namespace HeavenStudio.Editor
|
||||||
AddParams(entity);
|
AddParams(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static string TrackToThemeColour(int track) => track switch
|
|
||||||
{
|
|
||||||
1 => EditorTheme.theme.properties.Layer2Col,
|
|
||||||
2 => EditorTheme.theme.properties.Layer3Col,
|
|
||||||
3 => EditorTheme.theme.properties.Layer4Col,
|
|
||||||
4 => EditorTheme.theme.properties.Layer5Col,
|
|
||||||
_ => EditorTheme.theme.properties.Layer1Col
|
|
||||||
};
|
|
||||||
|
|
||||||
private void AddParams(RiqEntity entity)
|
private void AddParams(RiqEntity entity)
|
||||||
{
|
{
|
||||||
string[] split = entity.datamodel.Split('/');
|
string[] split = entity.datamodel.Split('/');
|
||||||
|
|
@ -95,7 +96,7 @@ namespace HeavenStudio.Editor
|
||||||
eventSelector.SetActive(false);
|
eventSelector.SetActive(false);
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
|
|
||||||
string col = TrackToThemeColour((int)entity["track"]);
|
string col = EditorTheme.theme.properties.LayerColors[(int)entity["track"]];
|
||||||
Editor.instance.SetGameEventTitle($"Properties for <color=#{col}>{action.displayName}</color> on Beat {entity.beat.ToString("F2")} on <color=#{col}>Track {(int)entity["track"] + 1}</color>");
|
Editor.instance.SetGameEventTitle($"Properties for <color=#{col}>{action.displayName}</color> on Beat {entity.beat.ToString("F2")} on <color=#{col}>Track {(int)entity["track"] + 1}</color>");
|
||||||
|
|
||||||
DestroyParams();
|
DestroyParams();
|
||||||
|
|
@ -104,11 +105,8 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
for (int i = 0; i < action.parameters.Count; i++)
|
for (int i = 0; i < action.parameters.Count; i++)
|
||||||
{
|
{
|
||||||
object param = action.parameters[i].parameter;
|
var p = action.parameters[i];
|
||||||
string caption = action.parameters[i].propertyCaption;
|
ePrefabs.Add(p.propertyName, AddParam(p.propertyName, p.parameter, p.caption, p.tooltip));
|
||||||
string propertyName = action.parameters[i].propertyName;
|
|
||||||
string tooltip = action.parameters[i].tooltip;
|
|
||||||
ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var p in action.parameters)
|
foreach (var p in action.parameters)
|
||||||
|
|
@ -133,57 +131,15 @@ 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 = "")
|
||||||
{
|
{
|
||||||
GameObject input;
|
if (!PropertyPrefabs.TryGetValue(type.GetType(), out GameObject propertyPrefab)) {
|
||||||
|
|
||||||
var objType = type.GetType();
|
|
||||||
|
|
||||||
if (objType == typeof(EntityTypes.Integer))
|
|
||||||
{
|
|
||||||
input = InitPrefab(IntegerP, tooltip);
|
|
||||||
var property = input.GetComponent<BoolPropertyPrefab>();
|
|
||||||
property.SetProperties(propertyName, type, caption);
|
|
||||||
}
|
|
||||||
else if (objType == typeof(EntityTypes.Float))
|
|
||||||
{
|
|
||||||
input = InitPrefab(FloatP, tooltip);
|
|
||||||
var property = input.GetComponent<NumberPropertyPrefab>();
|
|
||||||
property.SetProperties(propertyName, type, caption);
|
|
||||||
}
|
|
||||||
else if (objType == typeof(EntityTypes.Button))
|
|
||||||
{
|
|
||||||
input = InitPrefab(ButtonP, tooltip);
|
|
||||||
var property = input.GetComponent<ButtonPropertyPrefab>();
|
|
||||||
property.SetProperties(propertyName, type, caption);
|
|
||||||
}
|
|
||||||
else if (objType == typeof(bool))
|
|
||||||
{
|
|
||||||
input = InitPrefab(BooleanP, tooltip);
|
|
||||||
var property = input.GetComponent<BoolPropertyPrefab>();
|
|
||||||
property.SetProperties(propertyName, type, caption);
|
|
||||||
}
|
|
||||||
else if (objType.IsEnum || objType == typeof(string[]))
|
|
||||||
{
|
|
||||||
input = InitPrefab(DropdownP, tooltip);
|
|
||||||
var property = input.GetComponent<DropdownPropertyPrefab>();
|
|
||||||
property.SetProperties(propertyName, type, caption);
|
|
||||||
}
|
|
||||||
else if (objType == typeof(Color))
|
|
||||||
{
|
|
||||||
input = InitPrefab(ColorP, tooltip);
|
|
||||||
var property = input.GetComponent<ColorPropertyPrefab>();
|
|
||||||
property.SetProperties(propertyName, type, caption);
|
|
||||||
}
|
|
||||||
else if (objType == typeof(string))
|
|
||||||
{
|
|
||||||
input = InitPrefab(StringP, tooltip);
|
|
||||||
var property = input.GetComponent<StringPropertyPrefab>();
|
|
||||||
property.SetProperties(propertyName, type, caption);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("Can't make property interface of type: " + type.GetType());
|
Debug.LogError("Can't make property interface of type: " + type.GetType());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameObject input = InitPrefab(propertyPrefab, tooltip);
|
||||||
|
EventPropertyPrefab property = input.GetComponent<EventPropertyPrefab>();
|
||||||
|
property.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
|
||||||
using Jukebox;
|
using Jukebox;
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
|
|
@ -20,10 +18,7 @@ namespace HeavenStudio.Editor
|
||||||
public string propertyName;
|
public string propertyName;
|
||||||
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
||||||
|
|
||||||
public void SetProperties(string propertyName, object type, string caption) {}
|
public virtual void SetProperties(string propertyName, object type, string caption)
|
||||||
public virtual void SetCollapses(object type) { }
|
|
||||||
|
|
||||||
public void InitProperties(string propertyName, string caption)
|
|
||||||
{
|
{
|
||||||
this.parameterManager = EventParameterManager.instance;
|
this.parameterManager = EventParameterManager.instance;
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
|
|
@ -32,6 +27,7 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
this.caption.text = _captionText;
|
this.caption.text = _captionText;
|
||||||
}
|
}
|
||||||
|
public virtual void SetCollapses(object type) { }
|
||||||
|
|
||||||
public void UpdateCollapse(object type)
|
public void UpdateCollapse(object type)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,6 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
|
||||||
using HeavenStudio.Editor;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
public class BoolPropertyPrefab : EventPropertyPrefab
|
public class BoolPropertyPrefab : EventPropertyPrefab
|
||||||
|
|
@ -20,9 +16,9 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
private bool _defaultValue;
|
private bool _defaultValue;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
public override void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
_defaultValue = (bool)type;
|
_defaultValue = (bool)type;
|
||||||
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
|
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ using UnityEngine.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
using Jukebox;
|
||||||
using HeavenStudio.Util;
|
|
||||||
using HeavenStudio.Editor;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -16,14 +14,18 @@ namespace HeavenStudio.Editor
|
||||||
[Header("Boolean")]
|
[Header("Boolean")]
|
||||||
[Space(10)]
|
[Space(10)]
|
||||||
// public Button buttonObj;
|
// public Button buttonObj;
|
||||||
|
public TMP_Text buttonText;
|
||||||
public EntityTypes.Button button;
|
public EntityTypes.Button button;
|
||||||
|
public RiqEntity entity;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
public override void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, 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;
|
||||||
} 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;
|
||||||
|
|
@ -32,7 +34,10 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
public void OnClick()
|
public void OnClick()
|
||||||
{
|
{
|
||||||
button.onClick.Invoke();
|
string text = button.onClick.Invoke(entity);
|
||||||
|
if (text != null) {
|
||||||
|
buttonText.text = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,10 +6,6 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
|
||||||
using HeavenStudio.Editor;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
public class ColorPropertyPrefab : EventPropertyPrefab
|
public class ColorPropertyPrefab : EventPropertyPrefab
|
||||||
|
|
@ -24,9 +20,9 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
private Color _defaultColor;
|
private Color _defaultColor;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
public override void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
hex.onSelect.AddListener(
|
hex.onSelect.AddListener(
|
||||||
_ =>
|
_ =>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
|
||||||
using HeavenStudio.Editor;
|
|
||||||
using HeavenStudio.Common;
|
using HeavenStudio.Common;
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
|
|
@ -17,52 +15,46 @@ namespace HeavenStudio.Editor
|
||||||
[Header("Dropdown")]
|
[Header("Dropdown")]
|
||||||
[Space(10)]
|
[Space(10)]
|
||||||
public LeftClickTMP_Dropdown dropdown;
|
public LeftClickTMP_Dropdown dropdown;
|
||||||
private Array values;
|
// private string[] values;
|
||||||
|
private List<string> names;
|
||||||
|
private List<(int, string)> values;
|
||||||
|
|
||||||
private int _defaultValue;
|
private int _defaultValue;
|
||||||
|
|
||||||
private bool openedDropdown = false;
|
private bool openedDropdown = false;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
public override void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
var enumType = type.GetType();
|
// var enumType = type.GetType();
|
||||||
values = Enum.GetValues(enumType);
|
// values = Enum.GetValues(enumType).Cast<string>().ToArray();
|
||||||
var enumNames = Enum.GetNames(enumType).ToList();
|
// names = Enum.GetNames(enumType).ToList();
|
||||||
_defaultValue = (int)type;
|
// _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]
|
||||||
var currentlySelected = (int) parameterManager.entity[propertyName];
|
// var currentlySelected = (int) parameterManager.entity[propertyName];
|
||||||
var selected = values
|
// var selected = values
|
||||||
.Cast<object>()
|
// .Cast<object>()
|
||||||
.ToList()
|
// .ToList()
|
||||||
.FindIndex(val => (int) val == currentlySelected);
|
// .FindIndex(val => (int) val == currentlySelected);
|
||||||
|
|
||||||
dropdown.AddOptions(enumNames);
|
if (type is not EntityTypes.Dropdown dropdownEntity) return;
|
||||||
dropdown.value = selected;
|
|
||||||
|
|
||||||
dropdown.onValueChanged.AddListener(_ =>
|
names = dropdownEntity.values;
|
||||||
{
|
dropdown.AddOptions(names);
|
||||||
parameterManager.entity[propertyName] = GetValue();
|
dropdown.value = (int)parameterManager.entity[propertyName];
|
||||||
if (GetValue() != _defaultValue)
|
|
||||||
|
dropdown.onValueChanged.AddListener(newValue =>
|
||||||
{
|
{
|
||||||
this.caption.text = _captionText + "*";
|
parameterManager.entity[propertyName] = newValue;
|
||||||
|
Debug.Log("newValue : " + newValue);
|
||||||
|
this.caption.text = (newValue != _defaultValue) ? (_captionText + "*") : _captionText;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
this.caption.text = _captionText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetValue()
|
|
||||||
{
|
|
||||||
return (int)values.GetValue(dropdown.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetValue()
|
public void ResetValue()
|
||||||
{
|
{
|
||||||
dropdown.value = _defaultValue;
|
dropdown.value = _defaultValue;
|
||||||
|
|
@ -70,8 +62,8 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
public override void SetCollapses(object type)
|
public override void SetCollapses(object type)
|
||||||
{
|
{
|
||||||
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(GetValue()));
|
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(type));
|
||||||
UpdateCollapse(GetValue());
|
UpdateCollapse(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,6 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
|
||||||
using HeavenStudio.Editor;
|
|
||||||
using static HeavenStudio.EntityTypes;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
public class NumberPropertyPrefab : EventPropertyPrefab
|
public class NumberPropertyPrefab : EventPropertyPrefab
|
||||||
|
|
@ -22,9 +17,9 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
private float _defaultValue;
|
private float _defaultValue;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
public override void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|
@ -141,19 +136,8 @@ namespace HeavenStudio.Editor
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case EntityTypes.Integer integer:
|
case EntityTypes.Integer integer:
|
||||||
slider.onValueChanged.AddListener(
|
slider.onValueChanged.AddListener(_ => UpdateCollapse((int)slider.value));
|
||||||
_ =>
|
inputField.onEndEdit.AddListener(_ => UpdateCollapse((int)slider.value));
|
||||||
{
|
|
||||||
UpdateCollapse((int)slider.value);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
inputField.onEndEdit.AddListener(
|
|
||||||
_ =>
|
|
||||||
{
|
|
||||||
UpdateCollapse((int)slider.value);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
UpdateCollapse((int)slider.value);
|
UpdateCollapse((int)slider.value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
private string _defaultValue;
|
private string _defaultValue;
|
||||||
|
|
||||||
new public void SetProperties(string propertyName, object type, string caption)
|
public override void SetProperties(string propertyName, object type, string caption)
|
||||||
{
|
{
|
||||||
InitProperties(propertyName, caption);
|
base.SetProperties(propertyName, type, caption);
|
||||||
|
|
||||||
_defaultValue = (string)type;
|
_defaultValue = (string)type;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -890,16 +890,19 @@ namespace HeavenStudio.Editor.Track
|
||||||
{
|
{
|
||||||
object returnVal = ep[i].parameter;
|
object returnVal = ep[i].parameter;
|
||||||
|
|
||||||
var propertyType = returnVal.GetType();
|
if (returnVal is EntityTypes.Integer intVal)
|
||||||
if (propertyType == typeof(EntityTypes.Integer))
|
|
||||||
{
|
{
|
||||||
returnVal = ((EntityTypes.Integer)ep[i].parameter).val;
|
returnVal = intVal.val;
|
||||||
}
|
}
|
||||||
else if (propertyType == typeof(EntityTypes.Float))
|
else if (returnVal is EntityTypes.Float floatVal)
|
||||||
{
|
{
|
||||||
returnVal = ((EntityTypes.Float)ep[i].parameter).val;
|
returnVal = floatVal.val;
|
||||||
}
|
}
|
||||||
else if (propertyType.IsEnum)
|
else if (returnVal is EntityTypes.Dropdown dropdownVal)
|
||||||
|
{
|
||||||
|
returnVal = dropdownVal.defaultValue;
|
||||||
|
}
|
||||||
|
else if (returnVal.GetType().IsEnum)
|
||||||
{
|
{
|
||||||
returnVal = (int)ep[i].parameter;
|
returnVal = (int)ep[i].parameter;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,8 @@ using Jukebox;
|
||||||
using SatorImaging.UnitySourceGenerator;
|
using SatorImaging.UnitySourceGenerator;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace HeavenStudio
|
namespace HeavenStudio
|
||||||
{
|
{
|
||||||
|
|
@ -673,7 +672,7 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
public string propertyName;
|
public string propertyName;
|
||||||
public object parameter;
|
public object parameter;
|
||||||
public string propertyCaption;
|
public string caption;
|
||||||
public string tooltip;
|
public string tooltip;
|
||||||
public List<CollapseParam> collapseParams;
|
public List<CollapseParam> collapseParams;
|
||||||
|
|
||||||
|
|
@ -682,12 +681,15 @@ namespace HeavenStudio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="propertyName">The name of the variable that's being changed.</param>
|
/// <param name="propertyName">The name of the variable that's being changed.</param>
|
||||||
/// <param name="parameter">The value of the parameter</param>
|
/// <param name="parameter">The value of the parameter</param>
|
||||||
/// <param name="propertyCaption">The name shown in the editor. Can be anything you want.</param>
|
/// <param name="caption">The name shown in the editor. Can be anything you want.</param>
|
||||||
public Param(string propertyName, object parameter, string propertyCaption, string tooltip = "", List<CollapseParam> collapseParams = null)
|
public Param(string propertyName, object parameter, string caption, string tooltip = "", List<CollapseParam> collapseParams = null)
|
||||||
{
|
{
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
this.parameter = parameter;
|
this.parameter = parameter switch {
|
||||||
this.propertyCaption = propertyCaption;
|
// Enum param => new EntityTypes.Dropdown(param),
|
||||||
|
_ => parameter,
|
||||||
|
};
|
||||||
|
this.caption = caption;
|
||||||
this.tooltip = tooltip;
|
this.tooltip = tooltip;
|
||||||
this.collapseParams = collapseParams;
|
this.collapseParams = collapseParams;
|
||||||
}
|
}
|
||||||
|
|
@ -835,7 +837,7 @@ namespace HeavenStudio
|
||||||
|
|
||||||
new Minigame("vfx", "Visual Effects", "", false, true, new List<GameAction>()
|
new Minigame("vfx", "Visual Effects", "", false, true, new List<GameAction>()
|
||||||
{
|
{
|
||||||
new GameAction("flash", "Flash", 1f, true,
|
new GameAction("flash", "Flash/Fade", 1f, true,
|
||||||
new List<Param>()
|
new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("colorA", Color.white, "Start Color", "Set the color at the start of the event."),
|
new Param("colorA", Color.white, "Start Color", "Set the color at the start of the event."),
|
||||||
|
|
@ -1160,12 +1162,18 @@ namespace HeavenStudio
|
||||||
new GameAction("play animation", "Play Animation", 0.5f, false,
|
new GameAction("play animation", "Play Animation", 0.5f, false,
|
||||||
new List<Param>()
|
new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("getAnimators", new EntityTypes.Button("Get Animators", delegate {
|
new Param("getAnimators", new EntityTypes.Button("No Game", e => {
|
||||||
string gameName = GameManager.instance.currentGame;
|
var gm = GameManager.instance;
|
||||||
return gameName;
|
Minigame game = gm.GetGameInfo(gm.currentGame);
|
||||||
}), "Button", "Specify which animator in the scene to play an animation on. (i.e \"Plalin\" or \"Game/Paddlers/Player\")"),
|
if (game != null) {
|
||||||
new Param("animator", "", "Animator", "Specify which animator in the scene to play an animation on. (i.e \"Plalin\" or \"Game/Paddlers/Player\")"),
|
gm.minigameAnimators = gm.minigameObj.transform.GetComponentsInChildren<Animator>();
|
||||||
new Param("animation", "", "Animation", "Specify the name of the animation to play."),
|
e["animators"].values = gm.minigameAnimators.Select(x => x.name).ToList();
|
||||||
|
e["animations"] = gm.minigameAnimators[0].runtimeAnimatorController.animationClips.Select(x => x.name).ToList();
|
||||||
|
}
|
||||||
|
return game?.displayName ?? "No Game";
|
||||||
|
}), "Button", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"),
|
||||||
|
new Param("animators", new EntityTypes.Dropdown(0, "N/A"), "Animator", "Specify which animator in the scene to play an animation on. (i.e \"Plalin\" or \"Game/Paddlers/Player\")"),
|
||||||
|
new Param("animations", new EntityTypes.Dropdown(0, "N/A"), "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 {
|
||||||
|
|
@ -1199,3 +1207,57 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class EnumProcessor
|
||||||
|
{
|
||||||
|
private readonly Enum enumValue;
|
||||||
|
|
||||||
|
public EnumProcessor(Enum value)
|
||||||
|
{
|
||||||
|
if (!value.GetType().IsEnum)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Value must be an enum type.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.enumValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessEnumValue()
|
||||||
|
{
|
||||||
|
Type enumType = this.enumValue.GetType().DeclaringType;
|
||||||
|
|
||||||
|
if (enumType != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("EnumType: " + enumType.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("EnumValue: " + this.enumValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EnumExamples
|
||||||
|
{
|
||||||
|
public enum EnumExample
|
||||||
|
{
|
||||||
|
EnumValue1,
|
||||||
|
EnumValue2
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EnumAnotherExample
|
||||||
|
{
|
||||||
|
DifferentValue1,
|
||||||
|
DifferentValue2
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
EnumProcessor processor1 = new EnumProcessor(EnumExample.EnumValue1);
|
||||||
|
EnumProcessor processor2 = new EnumProcessor(EnumAnotherExample.DifferentValue1);
|
||||||
|
|
||||||
|
// Call the method for EnumExample
|
||||||
|
processor1.ProcessEnumValue();
|
||||||
|
|
||||||
|
// Call the method for EnumAnotherExample
|
||||||
|
processor2.ProcessEnumValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Jukebox;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace HeavenStudio
|
namespace HeavenStudio
|
||||||
|
|
@ -27,7 +29,7 @@ namespace HeavenStudio
|
||||||
public float val;
|
public float val;
|
||||||
public float max;
|
public float max;
|
||||||
|
|
||||||
public Float(float min, float max, float val = 0f)
|
public Float(float min, float max, float val = 0)
|
||||||
{
|
{
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.val = val;
|
this.val = val;
|
||||||
|
|
@ -35,18 +37,65 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this will eventually replace Float and Integer
|
||||||
|
public struct Number
|
||||||
|
{
|
||||||
|
public float snap;
|
||||||
|
public float min;
|
||||||
|
public float val;
|
||||||
|
public float max;
|
||||||
|
|
||||||
|
public Number(float snap, float min, float max, float val = 0)
|
||||||
|
{
|
||||||
|
this.snap = snap;
|
||||||
|
this.min = min;
|
||||||
|
this.val = val;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Number(float min, float max, float val = 0)
|
||||||
|
{
|
||||||
|
this.snap = 0.001f;
|
||||||
|
this.min = min;
|
||||||
|
this.val = val;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct Button
|
public struct Button
|
||||||
{
|
{
|
||||||
public string buttonLabel;
|
public string defaultLabel;
|
||||||
public Func<string> onClick;
|
public Func<RiqEntity, string> onClick;
|
||||||
|
|
||||||
public Button(string buttonLabel, Func<string> onClick)
|
public Button(string defaultLabel, Func<RiqEntity, string> onClick)
|
||||||
{
|
{
|
||||||
this.buttonLabel = buttonLabel;
|
this.defaultLabel = defaultLabel;
|
||||||
this.onClick = onClick;
|
this.onClick = onClick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct Dropdown
|
||||||
|
{
|
||||||
|
public int defaultValue;
|
||||||
|
public List<string> values;
|
||||||
|
|
||||||
|
// params List<> when 😢
|
||||||
|
public Dropdown(int defaultValue, params string[] values)
|
||||||
|
{
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.values = values.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dropdown(Enum value)
|
||||||
|
{
|
||||||
|
this.defaultValue = 0;
|
||||||
|
// Debug.Log(value);
|
||||||
|
// Debug.Log(value.GetType());
|
||||||
|
// Debug.Log(value.GetType().DeclaringType);
|
||||||
|
this.values = Enum.GetNames(value.GetType()).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct Resource
|
public struct Resource
|
||||||
{
|
{
|
||||||
public enum ResourceType
|
public enum ResourceType
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue