mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-11 09:58:02 +08:00
InteractiveValueStruct, and a few cleanups
This commit is contained in:
1 parent
26052621e5
commit
c828d9b642
17 files changed
+316
-92
No files matched your search
@@ -25,7 +25,7 @@ namespace UnityExplorer.UI.CacheObject
|
||||
public abstract bool IsStatic { get; }
|
||||
public override bool HasArguments => Arguments?.Length > 0 || GenericArguments.Length > 0;
|
||||
public ParameterInfo[] Arguments { get; protected set; } = new ParameterInfo[0];
|
||||
public Type[] GenericArguments { get; protected set; } = new Type[0];
|
||||
public Type[] GenericArguments { get; protected set; } = ArgumentUtility.EmptyTypes;
|
||||
public EvaluateWidget Evaluator { get; protected set; }
|
||||
public bool Evaluating => Evaluator != null && Evaluator.UIRoot.activeSelf;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace UnityExplorer.UI.CacheObject
|
||||
if (Arguments.Length > 0)
|
||||
return methodInfo.Invoke(DeclaringInstance, Evaluator.TryParseArguments());
|
||||
|
||||
var ret = methodInfo.Invoke(DeclaringInstance, new object[0]);
|
||||
var ret = methodInfo.Invoke(DeclaringInstance, ArgumentUtility.EmptyArgs);
|
||||
|
||||
HadException = false;
|
||||
LastException = null;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace UnityExplorer.UI.CacheObject
|
||||
|
||||
// internals
|
||||
|
||||
private static readonly Dictionary<string, MethodInfo> numberParseMethods = new Dictionary<string, MethodInfo>();
|
||||
// private static readonly Dictionary<string, MethodInfo> numberParseMethods = new Dictionary<string, MethodInfo>();
|
||||
|
||||
public ValueState State = ValueState.NotEvaluated;
|
||||
|
||||
@@ -160,25 +160,18 @@ namespace UnityExplorer.UI.CacheObject
|
||||
{
|
||||
if (type == typeof(bool))
|
||||
return ValueState.Boolean;
|
||||
|
||||
else if (type.IsPrimitive || type == typeof(decimal))
|
||||
return ValueState.Number;
|
||||
|
||||
else if (type == typeof(string))
|
||||
return ValueState.String;
|
||||
|
||||
else if (type.IsEnum)
|
||||
return ValueState.Enum;
|
||||
|
||||
else if (type == typeof(Color) || type == typeof(Color32))
|
||||
return ValueState.Color;
|
||||
|
||||
// else if (InteractiveValueStruct.SupportsType(type))
|
||||
// return ValueState.ValueStruct;
|
||||
|
||||
else if (InteractiveValueStruct.SupportsType(type))
|
||||
return ValueState.ValueStruct;
|
||||
else if (typeof(IDictionary).IsAssignableFrom(type))
|
||||
return ValueState.Dictionary;
|
||||
|
||||
else if (typeof(IEnumerable).IsAssignableFrom(type))
|
||||
return ValueState.Collection;
|
||||
else
|
||||
@@ -341,6 +334,8 @@ namespace UnityExplorer.UI.CacheObject
|
||||
|
||||
// CacheObjectCell Apply
|
||||
|
||||
// todo make this a reusable utility method
|
||||
|
||||
public virtual void OnCellApplyClicked()
|
||||
{
|
||||
if (State == ValueState.Boolean)
|
||||
@@ -349,14 +344,9 @@ namespace UnityExplorer.UI.CacheObject
|
||||
{
|
||||
try
|
||||
{
|
||||
var type = Value.GetActualType();
|
||||
if (!numberParseMethods.ContainsKey(type.AssemblyQualifiedName))
|
||||
{
|
||||
var method = type.GetMethod("Parse", new Type[] { typeof(string) });
|
||||
numberParseMethods.Add(type.AssemblyQualifiedName, method);
|
||||
}
|
||||
|
||||
var val = numberParseMethods[type.AssemblyQualifiedName]
|
||||
var type = Value.GetType();
|
||||
|
||||
var val = ReflectionUtility.GetMethodInfo(type, "Parse", ArgumentUtility.ParseArgs)
|
||||
.Invoke(null, new object[] { CellView.InputField.Text });
|
||||
|
||||
SetUserValue(val);
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace UnityExplorer.UI.CacheObject.Views
|
||||
|
||||
try
|
||||
{
|
||||
var parse = ReflectionUtility.GetMethodInfo(type, "Parse", new Type[] { typeof(string) });
|
||||
var parse = ReflectionUtility.GetMethodInfo(type, "Parse", ArgumentUtility.ParseArgs);
|
||||
outArgs[i] = parse.Invoke(null, new object[] { input });
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in new issue
Block a user