fix control style dropdowns
This commit is contained in:
parent
ca05fc5e41
commit
207c2ace3f
|
|
@ -1,14 +1,9 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using Starpelly;
|
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
|
||||||
using HeavenStudio.Editor;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -22,9 +17,9 @@ namespace HeavenStudio.Editor
|
||||||
{
|
{
|
||||||
InitProperties(diag, propertyName, caption);
|
InitProperties(diag, propertyName, caption);
|
||||||
|
|
||||||
var enumType = type.GetType();
|
Type enumType = type.GetType();
|
||||||
var enumVals = Enum.GetValues(enumType);
|
Array enumVals = Enum.GetValues(enumType);
|
||||||
var enumNames = Enum.GetNames(enumType).ToList();
|
List<string> enumNames = Enum.GetNames(enumType).ToList();
|
||||||
|
|
||||||
// Can we assume non-holey enum?
|
// Can we assume non-holey enum?
|
||||||
// If we can we can simplify to dropdown.value = (int) parameterManager.chart[propertyName]
|
// If we can we can simplify to dropdown.value = (int) parameterManager.chart[propertyName]
|
||||||
|
|
@ -38,7 +33,7 @@ namespace HeavenStudio.Editor
|
||||||
dropdown.value = selected;
|
dropdown.value = selected;
|
||||||
|
|
||||||
dropdown.onValueChanged.AddListener(_ =>
|
dropdown.onValueChanged.AddListener(_ =>
|
||||||
parameterManager.chart[propertyName] = (int) enumVals.GetValue(dropdown.value)
|
parameterManager.chart[propertyName] = Enum.ToObject(enumType, (int) enumVals.GetValue(dropdown.value))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,15 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
public void AddParam(RemixPropertiesDialog diag, string propertyName, object type, string caption, bool isReadOnly = false, string tooltip = "")
|
public void AddParam(RemixPropertiesDialog diag, string propertyName, object type, string caption, bool isReadOnly = false, string tooltip = "")
|
||||||
{
|
{
|
||||||
|
if (!Minigames.propertiesModel.ContainsKey(propertyName))
|
||||||
|
{
|
||||||
|
Debug.LogError("Property " + propertyName + " does not exist!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
GameObject prefab = diag.IntegerP;
|
GameObject prefab = diag.IntegerP;
|
||||||
GameObject input;
|
GameObject input;
|
||||||
|
|
||||||
var objType = type.GetType();
|
var objType = Minigames.propertiesModel[propertyName].GetType();
|
||||||
|
|
||||||
if (objType == typeof(EntityTypes.Integer))
|
if (objType == typeof(EntityTypes.Integer))
|
||||||
{
|
{
|
||||||
|
|
@ -83,13 +88,13 @@ namespace HeavenStudio.Editor
|
||||||
property.SetProperties(diag, propertyName, type, caption);
|
property.SetProperties(diag, propertyName, type, caption);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Debug.LogError("Can't make property interface of type: " + type.GetType());
|
Debug.LogError("Can't make property interface of type: " + objType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogError("Can't make property interface of type: " + type.GetType());
|
Debug.LogError("Can't make property interface of type: " + objType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,8 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
if (data.properties[prop.Key].GetType() == typeof(string))
|
if (data.properties[prop.Key].GetType() == typeof(string))
|
||||||
data.properties[prop.Key] = Enum.Parse(mType, (string)data.properties[prop.Key]);
|
data.properties[prop.Key] = Enum.Parse(mType, (string)data.properties[prop.Key]);
|
||||||
|
else
|
||||||
|
data.properties[prop.Key] = Enum.ToObject(mType, data.properties[prop.Key]);
|
||||||
}
|
}
|
||||||
// convert all JObjects to their respective types
|
// convert all JObjects to their respective types
|
||||||
else if (data.properties[prop.Key].GetType() == typeof(Newtonsoft.Json.Linq.JObject))
|
else if (data.properties[prop.Key].GetType() == typeof(Newtonsoft.Json.Linq.JObject))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue