mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
Cleanup, extend ParseUtility to dict keys
This commit is contained in:
parent
c04a864b74
commit
7b700cbe55
@ -92,7 +92,7 @@ namespace UnityExplorer
|
|||||||
public static string ReflectionExToString(this Exception e, bool innerMost = true)
|
public static string ReflectionExToString(this Exception e, bool innerMost = true)
|
||||||
{
|
{
|
||||||
if (innerMost)
|
if (innerMost)
|
||||||
e.GetInnerMostException();
|
e = e.GetInnerMostException();
|
||||||
|
|
||||||
return $"{e.GetType()}: {e.Message}";
|
return $"{e.GetType()}: {e.Message}";
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,6 @@ using System.Globalization;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
@ -264,7 +263,7 @@ namespace UnityExplorer
|
|||||||
if (!(obj is Quaternion quaternion))
|
if (!(obj is Quaternion quaternion))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Vector3 vector = Quaternion.ToEulerAngles(quaternion);
|
Vector3 vector = quaternion.eulerAngles;
|
||||||
|
|
||||||
return string.Format(en_US, "{0}, {1}, {2}", new object[]
|
return string.Format(en_US, "{0}, {1}, {2}", new object[]
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.Core.Runtime;
|
using UnityExplorer.Core.Runtime;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Utility
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Syntax-highlights a member's signature, by either the Type name or a Type and Member together.
|
/// Syntax-highlights a member's signature, by either the Type name or a Type and Member together.
|
@ -8,7 +8,7 @@ using UnityEngine;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityExplorer.Core.Runtime;
|
using UnityExplorer.Core.Runtime;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Utility
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
public static class ToStringUtility
|
public static class ToStringUtility
|
||||||
{
|
{
|
@ -41,10 +41,10 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
this.DisplayedKey = key.TryCast();
|
this.DisplayedKey = key.TryCast();
|
||||||
|
|
||||||
var type = DisplayedKey.GetType();
|
var type = DisplayedKey.GetType();
|
||||||
if (type == typeof(string) || (type.IsPrimitive && !(type == typeof(bool))))
|
if (ParseUtility.CanParse(type))
|
||||||
{
|
{
|
||||||
KeyInputWanted = true;
|
KeyInputWanted = true;
|
||||||
KeyInputText = DisplayedKey.ToString();
|
KeyInputText = ParseUtility.ToStringForInput(DisplayedKey, type);
|
||||||
KeyInputTypeText = SignatureHighlighter.Parse(type, false);
|
KeyInputTypeText = SignatureHighlighter.Parse(type, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -98,7 +98,13 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
|
|
||||||
TrySetUserValue(value);
|
TrySetUserValue(value);
|
||||||
|
|
||||||
SetDataToCell(CellView);
|
if (CellView != null)
|
||||||
|
SetDataToCell(CellView);
|
||||||
|
|
||||||
|
// If the owner's parent CacheObject is set, we are setting the value of an inspected struct.
|
||||||
|
// Set the inspector target as the value back to that parent cacheobject.
|
||||||
|
if (Owner.ParentCacheObject != null)
|
||||||
|
Owner.ParentCacheObject.SetUserValue(Owner.Target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void TrySetUserValue(object value);
|
public abstract void TrySetUserValue(object value);
|
||||||
@ -114,7 +120,12 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
ProcessOnEvaluate();
|
ProcessOnEvaluate();
|
||||||
|
|
||||||
if (this.IValue != null)
|
if (this.IValue != null)
|
||||||
this.IValue.SetValue(Value);
|
{
|
||||||
|
if (SubContentShowWanted)
|
||||||
|
this.IValue.SetValue(Value);
|
||||||
|
else
|
||||||
|
IValue.PendingValueWanted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ProcessOnEvaluate()
|
protected virtual void ProcessOnEvaluate()
|
||||||
@ -348,8 +359,6 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
|
|
||||||
// CacheObjectCell Apply
|
// CacheObjectCell Apply
|
||||||
|
|
||||||
// todo make this a reusable utility method
|
|
||||||
|
|
||||||
public virtual void OnCellApplyClicked()
|
public virtual void OnCellApplyClicked()
|
||||||
{
|
{
|
||||||
if (State == ValueState.Boolean)
|
if (State == ValueState.Boolean)
|
||||||
@ -399,6 +408,14 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
{
|
{
|
||||||
SubContentShowWanted = !SubContentShowWanted;
|
SubContentShowWanted = !SubContentShowWanted;
|
||||||
CellView.SubContentHolder.SetActive(SubContentShowWanted);
|
CellView.SubContentHolder.SetActive(SubContentShowWanted);
|
||||||
|
|
||||||
|
if (SubContentShowWanted && IValue.PendingValueWanted)
|
||||||
|
{
|
||||||
|
IValue.PendingValueWanted = false;
|
||||||
|
this.ProcessOnEvaluate();
|
||||||
|
this.SetDataToCell(this.CellView);
|
||||||
|
IValue.SetValue(this.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CellView.RefreshSubcontentButton();
|
CellView.RefreshSubcontentButton();
|
||||||
|
@ -61,7 +61,7 @@ namespace UnityExplorer.UI.CacheObject.Views
|
|||||||
|
|
||||||
KeyInspectButton = UIFactory.CreateButton(keyGroup, "KeyInspectButton", "Inspect", new Color(0.15f, 0.15f, 0.15f));
|
KeyInspectButton = UIFactory.CreateButton(keyGroup, "KeyInspectButton", "Inspect", new Color(0.15f, 0.15f, 0.15f));
|
||||||
UIFactory.SetLayoutElement(KeyInspectButton.Button.gameObject, minWidth: 60, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(KeyInspectButton.Button.gameObject, minWidth: 60, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
|
||||||
InspectButton.OnClick += KeyInspectClicked;
|
KeyInspectButton.OnClick += KeyInspectClicked;
|
||||||
|
|
||||||
// label
|
// label
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.UI.CacheObject;
|
||||||
|
@ -167,7 +167,8 @@ namespace UnityExplorer.UI.IValues
|
|||||||
|
|
||||||
var entry = cachedEntries[keyIndex];
|
var entry = cachedEntries[keyIndex];
|
||||||
entry.SetValueFromSource(value);
|
entry.SetValueFromSource(value);
|
||||||
entry.SetDataToCell(entry.CellView);
|
if (entry.CellView != null)
|
||||||
|
entry.SetDataToCell(entry.CellView);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.UI.CacheObject;
|
||||||
@ -84,7 +83,7 @@ namespace UnityExplorer.UI.IValues
|
|||||||
values.Add(ValueAtIdx(i).Name);
|
values.Add(ValueAtIdx(i).Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentOwner.SetUserValue(Enum.Parse(EnumType, string.Join(", ", values)));
|
CurrentOwner.SetUserValue(Enum.Parse(EnumType, string.Join(", ", values.ToArray())));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,9 @@ namespace UnityExplorer.UI.IValues
|
|||||||
|
|
||||||
var entry = cachedEntries[index];
|
var entry = cachedEntries[index];
|
||||||
entry.SetValueFromSource(value);
|
entry.SetValueFromSource(value);
|
||||||
entry.SetDataToCell(entry.CellView);
|
|
||||||
|
if (entry.CellView != null)
|
||||||
|
entry.SetDataToCell(entry.CellView);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
|
@ -39,6 +39,8 @@ namespace UnityExplorer.UI.IValues
|
|||||||
public CacheObjectBase CurrentOwner => m_owner;
|
public CacheObjectBase CurrentOwner => m_owner;
|
||||||
private CacheObjectBase m_owner;
|
private CacheObjectBase m_owner;
|
||||||
|
|
||||||
|
public bool PendingValueWanted;
|
||||||
|
|
||||||
public virtual void OnBorrowed(CacheObjectBase owner)
|
public virtual void OnBorrowed(CacheObjectBase owner)
|
||||||
{
|
{
|
||||||
if (this.m_owner != null)
|
if (this.m_owner != null)
|
||||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.UI.CacheObject;
|
||||||
|
@ -77,8 +77,12 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
Inspectors.Add(inspector);
|
Inspectors.Add(inspector);
|
||||||
inspector.Target = target;
|
inspector.Target = target;
|
||||||
|
|
||||||
if (sourceCache != null && inspector is ReflectionInspector ri)
|
if (sourceCache != null && sourceCache.CanWrite)
|
||||||
ri.ParentCacheObject = sourceCache;
|
{
|
||||||
|
// only set parent cache object if we are inspecting a struct, otherwise there is no point.
|
||||||
|
if (target.GetType().IsValueType && inspector is ReflectionInspector ri)
|
||||||
|
ri.ParentCacheObject = sourceCache;
|
||||||
|
}
|
||||||
|
|
||||||
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
||||||
inspector.UIRoot.transform.SetParent(InspectorPanel.Instance.ContentHolder.transform, false);
|
inspector.UIRoot.transform.SetParent(InspectorPanel.Instance.ContentHolder.transform, false);
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
|
@ -306,20 +306,10 @@
|
|||||||
<Compile Include="UI\UIFactory.cs" />
|
<Compile Include="UI\UIFactory.cs" />
|
||||||
<Compile Include="UI\UIManager.cs" />
|
<Compile Include="UI\UIManager.cs" />
|
||||||
<Compile Include="UI\Panels\PanelDragger.cs" />
|
<Compile Include="UI\Panels\PanelDragger.cs" />
|
||||||
<Compile Include="UI\Utility\SignatureHighlighter.cs" />
|
<Compile Include="Core\Utility\SignatureHighlighter.cs" />
|
||||||
<Compile Include="UI\Utility\ToStringUtility.cs" />
|
<Compile Include="Core\Utility\ToStringUtility.cs" />
|
||||||
<Compile Include="UI\Widgets\AutoComplete\AutoCompleter.cs" />
|
<Compile Include="UI\Widgets\AutoComplete\AutoCompleter.cs" />
|
||||||
<Compile Include="UI\Widgets\AutoComplete\TypeCompleter.cs" />
|
<Compile Include="UI\Widgets\AutoComplete\TypeCompleter.cs" />
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveBool.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveColor.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveDictionary.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveEnum.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveEnumerable.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveFlags.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveFloatStruct.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveNumber.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveString.cs" />
|
|
||||||
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveValue.cs" />
|
|
||||||
<Compile Include="UI\Models\ButtonRef.cs" />
|
<Compile Include="UI\Models\ButtonRef.cs" />
|
||||||
<Compile Include="UI\ObjectExplorer\ObjectSearch.cs" />
|
<Compile Include="UI\ObjectExplorer\ObjectSearch.cs" />
|
||||||
<Compile Include="UI\ObjectExplorer\SceneExplorer.cs" />
|
<Compile Include="UI\ObjectExplorer\SceneExplorer.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user