mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-17 08:37:49 +08:00
some early work on Reflection Inspector
This commit is contained in:
@ -1,108 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Reflection;
|
||||
//using UnityEngine;
|
||||
//using UnityExplorer.CacheObject;
|
||||
//using UnityExplorer.Helpers;
|
||||
//using UnityExplorer.UI.Shared;
|
||||
|
||||
//namespace UnityExplorer.UI.InteractiveValue
|
||||
//{
|
||||
// public class InteractiveValue
|
||||
// {
|
||||
// //public const float MAX_LABEL_WIDTH = 400f;
|
||||
// //public const string EVALUATE_LABEL = "<color=lime>Evaluate</color>";
|
||||
|
||||
// public CacheObjectBase OwnerCacheObject;
|
||||
|
||||
// public object Value { get; set; }
|
||||
// public Type ValueType;
|
||||
|
||||
// public string ButtonLabel => m_btnLabel ?? GetButtonLabel();
|
||||
// private string m_btnLabel;
|
||||
|
||||
// public MethodInfo ToStringMethod => m_toStringMethod ?? GetToStringMethod();
|
||||
// private MethodInfo m_toStringMethod;
|
||||
|
||||
// public virtual void Init()
|
||||
// {
|
||||
// UpdateValue();
|
||||
// }
|
||||
|
||||
// public virtual void UpdateValue()
|
||||
// {
|
||||
// GetButtonLabel();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// private MethodInfo GetToStringMethod()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// m_toStringMethod = ReflectionHelpers.GetActualType(Value).GetMethod("ToString", new Type[0])
|
||||
// ?? typeof(object).GetMethod("ToString", new Type[0]);
|
||||
|
||||
// // test invoke
|
||||
// m_toStringMethod.Invoke(Value, null);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// m_toStringMethod = typeof(object).GetMethod("ToString", new Type[0]);
|
||||
// }
|
||||
// return m_toStringMethod;
|
||||
// }
|
||||
|
||||
// public string GetButtonLabel()
|
||||
// {
|
||||
// if (Value == null) return null;
|
||||
|
||||
// var valueType = ReflectionHelpers.GetActualType(Value);
|
||||
|
||||
// string label;
|
||||
|
||||
// if (valueType == typeof(TextAsset))
|
||||
// {
|
||||
// var textAsset = Value as TextAsset;
|
||||
|
||||
// label = textAsset.text;
|
||||
|
||||
// if (label.Length > 10)
|
||||
// {
|
||||
// label = $"{label.Substring(0, 10)}...";
|
||||
// }
|
||||
|
||||
// label = $"\"{label}\" {textAsset.name} (<color={Syntax.Class_Instance}>UnityEngine.TextAsset</color>)";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString();
|
||||
|
||||
// var classColor = valueType.IsAbstract && valueType.IsSealed
|
||||
// ? Syntax.Class_Static
|
||||
// : Syntax.Class_Instance;
|
||||
|
||||
// string typeLabel = $"<color={classColor}>{valueType.FullName}</color>";
|
||||
|
||||
// if (Value is UnityEngine.Object)
|
||||
// {
|
||||
// label = label.Replace($"({valueType.FullName})", $"({typeLabel})");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (!label.Contains(valueType.FullName))
|
||||
// {
|
||||
// label += $" ({typeLabel})";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// label = label.Replace(valueType.FullName, typeLabel);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return m_btnLabel = label;
|
||||
// }
|
||||
// }
|
||||
//}
|
Reference in New Issue
Block a user