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
d24dce703d
commit
d8c1a45a2b
|
|
@ -55,6 +55,7 @@ MonoBehaviour:
|
|||
caption: {fileID: 161819469598736649}
|
||||
parameterManager: {fileID: 0}
|
||||
propertyName:
|
||||
buttonText: {fileID: 1122443660375095464}
|
||||
--- !u!114 &1492239408036616687
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ RectTransform:
|
|||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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_SizeDelta: {x: 10, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
|
|
@ -885,7 +885,7 @@ RectTransform:
|
|||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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_SizeDelta: {x: 20, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
|
|
@ -943,7 +943,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &872153477128913844
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -24624,7 +24624,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 1589389271}
|
||||
m_Direction: 2
|
||||
m_Value: 1
|
||||
m_Size: 0.44222867
|
||||
m_Size: 1
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
|
@ -30367,7 +30367,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, 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_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &1154875945
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace HeavenStudio
|
|||
public string currentGame { get; private set; }
|
||||
public GameObject minigameObj { 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 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)
|
||||
|
|
@ -1142,7 +1138,6 @@ namespace HeavenStudio
|
|||
minigameObj.transform.parent = eventCaller.GamesHolder.transform;
|
||||
minigameObj.transform.localScale = originalScale;
|
||||
minigameObj.name = game;
|
||||
mgAnimators = minigameObj.transform.GetComponentsInChildren<Animator>();
|
||||
|
||||
SetCurrentGame(game, useMinigameColor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Editor.Track;
|
||||
using Jukebox;
|
||||
using Jukebox.Legacy;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Windows.Forms;
|
||||
using static HeavenStudio.EntityTypes;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
|
|
@ -26,6 +23,7 @@ namespace HeavenStudio.Editor
|
|||
[SerializeField] private GameObject DropdownP;
|
||||
[SerializeField] private GameObject ColorP;
|
||||
[SerializeField] private GameObject StringP;
|
||||
private static Dictionary<Type, GameObject> PropertyPrefabs;
|
||||
|
||||
public RiqEntity entity;
|
||||
|
||||
|
|
@ -40,6 +38,18 @@ namespace HeavenStudio.Editor
|
|||
private void Awake()
|
||||
{
|
||||
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()
|
||||
|
|
@ -74,15 +84,6 @@ namespace HeavenStudio.Editor
|
|||
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)
|
||||
{
|
||||
string[] split = entity.datamodel.Split('/');
|
||||
|
|
@ -95,7 +96,7 @@ namespace HeavenStudio.Editor
|
|||
eventSelector.SetActive(false);
|
||||
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>");
|
||||
|
||||
DestroyParams();
|
||||
|
|
@ -104,11 +105,8 @@ namespace HeavenStudio.Editor
|
|||
|
||||
for (int i = 0; i < action.parameters.Count; i++)
|
||||
{
|
||||
object param = action.parameters[i].parameter;
|
||||
string caption = action.parameters[i].propertyCaption;
|
||||
string propertyName = action.parameters[i].propertyName;
|
||||
string tooltip = action.parameters[i].tooltip;
|
||||
ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip));
|
||||
var p = action.parameters[i];
|
||||
ePrefabs.Add(p.propertyName, AddParam(p.propertyName, p.parameter, p.caption, p.tooltip));
|
||||
}
|
||||
|
||||
foreach (var p in action.parameters)
|
||||
|
|
@ -133,57 +131,15 @@ namespace HeavenStudio.Editor
|
|||
|
||||
private GameObject AddParam(string propertyName, object type, string caption, string tooltip = "")
|
||||
{
|
||||
GameObject input;
|
||||
|
||||
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
|
||||
{
|
||||
if (!PropertyPrefabs.TryGetValue(type.GetType(), out GameObject propertyPrefab)) {
|
||||
Debug.LogError("Can't make property interface of type: " + type.GetType());
|
||||
return null;
|
||||
}
|
||||
|
||||
GameObject input = InitPrefab(propertyPrefab, tooltip);
|
||||
EventPropertyPrefab property = input.GetComponent<EventPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ using System;
|
|||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
|
|
@ -20,10 +18,7 @@ namespace HeavenStudio.Editor
|
|||
public string propertyName;
|
||||
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
||||
|
||||
public void SetProperties(string propertyName, object type, string caption) {}
|
||||
public virtual void SetCollapses(object type) { }
|
||||
|
||||
public void InitProperties(string propertyName, string caption)
|
||||
public virtual void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
this.parameterManager = EventParameterManager.instance;
|
||||
this.propertyName = propertyName;
|
||||
|
|
@ -32,6 +27,7 @@ namespace HeavenStudio.Editor
|
|||
|
||||
this.caption.text = _captionText;
|
||||
}
|
||||
public virtual void SetCollapses(object type) { }
|
||||
|
||||
public void UpdateCollapse(object type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,10 +6,6 @@ using System;
|
|||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class BoolPropertyPrefab : EventPropertyPrefab
|
||||
|
|
@ -20,9 +16,9 @@ namespace HeavenStudio.Editor
|
|||
|
||||
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;
|
||||
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ using UnityEngine.UI;
|
|||
using System;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
|
|
@ -16,14 +14,18 @@ namespace HeavenStudio.Editor
|
|||
[Header("Boolean")]
|
||||
[Space(10)]
|
||||
// public Button buttonObj;
|
||||
public TMP_Text buttonText;
|
||||
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) {
|
||||
this.button = button;
|
||||
buttonText.text = button.defaultLabel;
|
||||
} else {
|
||||
Debug.LogError("ButtonPropertyPrefab was unable to use " + type.GetType() + " as a Button.");
|
||||
return;
|
||||
|
|
@ -32,7 +34,10 @@ namespace HeavenStudio.Editor
|
|||
|
||||
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 TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class ColorPropertyPrefab : EventPropertyPrefab
|
||||
|
|
@ -24,9 +20,9 @@ namespace HeavenStudio.Editor
|
|||
|
||||
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(
|
||||
_ =>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ using System;
|
|||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
using HeavenStudio.Common;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
|
|
@ -17,52 +15,46 @@ namespace HeavenStudio.Editor
|
|||
[Header("Dropdown")]
|
||||
[Space(10)]
|
||||
public LeftClickTMP_Dropdown dropdown;
|
||||
private Array values;
|
||||
// private string[] values;
|
||||
private List<string> names;
|
||||
private List<(int, string)> values;
|
||||
|
||||
private int _defaultValue;
|
||||
|
||||
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();
|
||||
values = Enum.GetValues(enumType);
|
||||
var enumNames = Enum.GetNames(enumType).ToList();
|
||||
_defaultValue = (int)type;
|
||||
// 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];
|
||||
var selected = values
|
||||
.Cast<object>()
|
||||
.ToList()
|
||||
.FindIndex(val => (int) val == currentlySelected);
|
||||
// var currentlySelected = (int) parameterManager.entity[propertyName];
|
||||
// var selected = values
|
||||
// .Cast<object>()
|
||||
// .ToList()
|
||||
// .FindIndex(val => (int) val == currentlySelected);
|
||||
|
||||
dropdown.AddOptions(enumNames);
|
||||
dropdown.value = selected;
|
||||
if (type is not EntityTypes.Dropdown dropdownEntity) return;
|
||||
|
||||
dropdown.onValueChanged.AddListener(_ =>
|
||||
{
|
||||
parameterManager.entity[propertyName] = GetValue();
|
||||
if (GetValue() != _defaultValue)
|
||||
names = dropdownEntity.values;
|
||||
dropdown.AddOptions(names);
|
||||
dropdown.value = (int)parameterManager.entity[propertyName];
|
||||
|
||||
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()
|
||||
{
|
||||
dropdown.value = _defaultValue;
|
||||
|
|
@ -70,8 +62,8 @@ namespace HeavenStudio.Editor
|
|||
|
||||
public override void SetCollapses(object type)
|
||||
{
|
||||
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(GetValue()));
|
||||
UpdateCollapse(GetValue());
|
||||
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(type));
|
||||
UpdateCollapse(type);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ using System;
|
|||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
using static HeavenStudio.EntityTypes;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class NumberPropertyPrefab : EventPropertyPrefab
|
||||
|
|
@ -22,9 +17,9 @@ namespace HeavenStudio.Editor
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
@ -141,19 +136,8 @@ namespace HeavenStudio.Editor
|
|||
switch (type)
|
||||
{
|
||||
case EntityTypes.Integer integer:
|
||||
slider.onValueChanged.AddListener(
|
||||
_ =>
|
||||
{
|
||||
UpdateCollapse((int)slider.value);
|
||||
}
|
||||
);
|
||||
|
||||
inputField.onEndEdit.AddListener(
|
||||
_ =>
|
||||
{
|
||||
UpdateCollapse((int)slider.value);
|
||||
}
|
||||
);
|
||||
slider.onValueChanged.AddListener(_ => UpdateCollapse((int)slider.value));
|
||||
inputField.onEndEdit.AddListener(_ => UpdateCollapse((int)slider.value));
|
||||
|
||||
UpdateCollapse((int)slider.value);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace HeavenStudio.Editor
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -890,16 +890,19 @@ namespace HeavenStudio.Editor.Track
|
|||
{
|
||||
object returnVal = ep[i].parameter;
|
||||
|
||||
var propertyType = returnVal.GetType();
|
||||
if (propertyType == typeof(EntityTypes.Integer))
|
||||
if (returnVal is EntityTypes.Integer intVal)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@ using Jukebox;
|
|||
using SatorImaging.UnitySourceGenerator;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace HeavenStudio
|
||||
{
|
||||
|
|
@ -673,7 +672,7 @@ namespace HeavenStudio
|
|||
{
|
||||
public string propertyName;
|
||||
public object parameter;
|
||||
public string propertyCaption;
|
||||
public string caption;
|
||||
public string tooltip;
|
||||
public List<CollapseParam> collapseParams;
|
||||
|
||||
|
|
@ -682,12 +681,15 @@ namespace HeavenStudio
|
|||
/// </summary>
|
||||
/// <param name="propertyName">The name of the variable that's being changed.</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>
|
||||
public Param(string propertyName, object parameter, string propertyCaption, string tooltip = "", List<CollapseParam> collapseParams = null)
|
||||
/// <param name="caption">The name shown in the editor. Can be anything you want.</param>
|
||||
public Param(string propertyName, object parameter, string caption, string tooltip = "", List<CollapseParam> collapseParams = null)
|
||||
{
|
||||
this.propertyName = propertyName;
|
||||
this.parameter = parameter;
|
||||
this.propertyCaption = propertyCaption;
|
||||
this.parameter = parameter switch {
|
||||
// Enum param => new EntityTypes.Dropdown(param),
|
||||
_ => parameter,
|
||||
};
|
||||
this.caption = caption;
|
||||
this.tooltip = tooltip;
|
||||
this.collapseParams = collapseParams;
|
||||
}
|
||||
|
|
@ -835,7 +837,7 @@ namespace HeavenStudio
|
|||
|
||||
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 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 List<Param>()
|
||||
{
|
||||
new Param("getAnimators", new EntityTypes.Button("Get Animators", delegate {
|
||||
string gameName = GameManager.instance.currentGame;
|
||||
return gameName;
|
||||
}), "Button", "Specify which animator in the scene to play an animation on. (i.e \"Plalin\" or \"Game/Paddlers/Player\")"),
|
||||
new Param("animator", "", "Animator", "Specify which animator in the scene to play an animation on. (i.e \"Plalin\" or \"Game/Paddlers/Player\")"),
|
||||
new Param("animation", "", "Animation", "Specify the name of the animation to play."),
|
||||
new Param("getAnimators", new EntityTypes.Button("No Game", e => {
|
||||
var gm = GameManager.instance;
|
||||
Minigame game = gm.GetGameInfo(gm.currentGame);
|
||||
if (game != null) {
|
||||
gm.minigameAnimators = gm.minigameObj.transform.GetComponentsInChildren<Animator>();
|
||||
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."),
|
||||
},
|
||||
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.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jukebox;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio
|
||||
|
|
@ -27,7 +29,7 @@ namespace HeavenStudio
|
|||
public float val;
|
||||
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.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 string buttonLabel;
|
||||
public Func<string> onClick;
|
||||
public string defaultLabel;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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 enum ResourceType
|
||||
|
|
|
|||
Loading…
Reference in a new issue