prepare automated property interface creation

This commit is contained in:
minenice55 2022-08-27 00:20:56 -04:00
parent 2b4b7f0a73
commit b19afcd2e2
3 changed files with 4761 additions and 4 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,92 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace HeavenStudio.Editor
{
public class ChartInfoProperties : MonoBehaviour
{
[Header("General References")]
[SerializeField] private GameObject propertyHolder;
[Header("Editable Properties")]
[SerializeField] private string[] propertyNames;
[Header("Property Prefabs")]
[SerializeField] private GameObject IntegerP;
[SerializeField] private GameObject FloatP;
[SerializeField] private GameObject BooleanP;
[SerializeField] private GameObject DropdownP;
[SerializeField] private GameObject ColorP;
[SerializeField] private GameObject StringP;
private void AddParam(string propertyName, object type, string caption, string tooltip = "")
{
GameObject prefab = IntegerP;
GameObject input;
var objType = type.GetType();
if (objType == typeof(EntityTypes.Integer))
{
prefab = IntegerP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<NumberPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
}
else if (objType == typeof(EntityTypes.Float))
{
prefab = FloatP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<NumberPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
}
else if (type is bool)
{
prefab = BooleanP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<BoolPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
}
else if (objType.IsEnum)
{
prefab = DropdownP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<EnumPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
}
else if (objType == typeof(Color))
{
prefab = ColorP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<ColorPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
}
else if (objType == typeof(string))
{
prefab = StringP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<StringPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
}
else
{
Debug.LogError("Can't make property interface of type: " + type.GetType());
return;
}
}
private GameObject InitPrefab(GameObject prefab, string tooltip = "")
{
GameObject input = Instantiate(prefab);
input.transform.SetParent(propertyHolder.transform);
input.SetActive(true);
input.transform.localScale = Vector2.one;
if(tooltip != string.Empty)
Tooltip.AddTooltip(input, "", tooltip);
return input;
}
}
}

View file

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