2020-08-22 00:16:05 +10:00
|
|
|
|
using System;
|
2020-08-22 17:17:11 +10:00
|
|
|
|
using System.Collections;
|
2020-08-22 00:16:05 +10:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-08-22 17:17:11 +10:00
|
|
|
|
using System.Reflection;
|
2020-08-22 00:16:05 +10:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Explorer
|
|
|
|
|
{
|
2020-08-29 21:15:54 +10:00
|
|
|
|
public class CacheOther : CacheObjectBase
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
2020-08-22 17:17:11 +10:00
|
|
|
|
private MethodInfo m_toStringMethod;
|
|
|
|
|
|
|
|
|
|
public MethodInfo ToStringMethod
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
2020-08-22 17:17:11 +10:00
|
|
|
|
get
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
2020-09-01 18:03:44 +10:00
|
|
|
|
if (m_toStringMethod == null)
|
2020-08-22 17:17:11 +10:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2020-09-01 18:03:44 +10:00
|
|
|
|
m_toStringMethod = ReflectionHelpers.GetActualType(Value).GetMethod("ToString", new Type[0])
|
|
|
|
|
?? typeof(object).GetMethod("ToString", new Type[0]);
|
2020-08-22 17:17:11 +10:00
|
|
|
|
|
2020-09-01 18:03:44 +10:00
|
|
|
|
// test invoke
|
|
|
|
|
m_toStringMethod.Invoke(Value, null);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
m_toStringMethod = typeof(object).GetMethod("ToString", new Type[0]);
|
2020-08-22 17:17:11 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return m_toStringMethod;
|
2020-08-22 00:16:05 +10:00
|
|
|
|
}
|
2020-08-22 17:17:11 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void DrawValue(Rect window, float width)
|
|
|
|
|
{
|
|
|
|
|
string label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString();
|
|
|
|
|
|
2020-09-01 18:03:44 +10:00
|
|
|
|
if (!label.Contains(ValueTypeName))
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
2020-09-01 18:03:44 +10:00
|
|
|
|
label += $" ({ValueTypeName})";
|
2020-08-22 00:16:05 +10:00
|
|
|
|
}
|
2020-08-22 17:17:11 +10:00
|
|
|
|
if (Value is UnityEngine.Object unityObj && !label.Contains(unityObj.name))
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
2020-08-22 17:17:11 +10:00
|
|
|
|
label = unityObj.name + " | " + label;
|
2020-08-22 00:16:05 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
|
2020-09-08 04:33:27 +10:00
|
|
|
|
if (GUILayout.Button("<color=yellow>" + label + "</color>", new GUILayoutOption[] { GUILayout.Width(width - 15) }))
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
|
|
|
|
WindowManager.InspectObject(Value, out bool _);
|
|
|
|
|
}
|
|
|
|
|
GUI.skin.button.alignment = TextAnchor.MiddleCenter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|