Entity object parameters testing

This commit is contained in:
Braedon
2022-02-03 17:20:26 -05:00
parent 95637635f6
commit e0db2a446e
27 changed files with 1413 additions and 264 deletions

View File

@ -0,0 +1,76 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RhythmHeavenMania.Editor
{
public class EventParameterManager : MonoBehaviour
{
[Header("General References")]
[SerializeField] private GameObject eventSelector;
[Header("Property Prefabs")]
[SerializeField] private GameObject IntegerP;
public Beatmap.Entity entity;
public static EventParameterManager instance { get; set; }
private void Awake()
{
instance = this;
}
public void StartParams(Beatmap.Entity entity)
{
AddParams(entity);
}
private void AddParams(Beatmap.Entity entity)
{
var minigame = EventCaller.instance.GetMinigame(entity.datamodel.Split(0));
int actionIndex = minigame.actions.IndexOf(minigame.actions.Find(c => c.actionName == entity.datamodel.Split(1)));
Minigames.GameAction action = minigame.actions[actionIndex];
if (action.parameters != null)
{
eventSelector.SetActive(false);
this.entity = entity;
Editor.instance.SetGameEventTitle($"Properties for {entity.datamodel}");
for (int i = 1; i < transform.childCount; i++)
{
Destroy(transform.GetChild(i).gameObject);
}
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;
AddParam(propertyName, param, caption);
}
}
}
private void AddParam(string propertyName, object type, string caption)
{
GameObject prefab = IntegerP;
if (type.GetType() == typeof(EntityTypes.Integer))
{
prefab = IntegerP;
}
GameObject input = Instantiate(prefab);
input.transform.SetParent(this.gameObject.transform);
input.SetActive(true);
input.transform.localScale = Vector2.one;
var property = input.GetComponent<EventPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c8ae907a3485c8a43b30312182de8b1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace RhythmHeavenMania.Editor
{
public class EventPropertyPrefab : MonoBehaviour
{
public TMP_Text caption;
public Slider slider;
public TMP_InputField inputField;
private string propertyName;
[SerializeField] private EventParameterManager parameterManager;
public void SetProperties(string propertyName, object type, string caption)
{
this.propertyName = propertyName;
this.caption.text = caption;
var integer = ((EntityTypes.Integer)type);
slider.minValue = integer.min;
slider.maxValue = integer.max;
}
public void TestChange()
{
inputField.text = slider.value.ToString();
parameterManager.entity[propertyName] = (int)slider.value;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3b7c76a246115c1459c963e93f7db056
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: