mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-09-20 21:46:02 +08:00
Handle boxing value types to Il2CppSystem.Object, some cleanups
This commit is contained in:
@ -43,7 +43,7 @@ namespace UnityExplorer.UI.CacheObject
|
||||
{
|
||||
try
|
||||
{
|
||||
FieldInfo.SetValue(FieldInfo.IsStatic ? null : Owner.Target.TryCast(this.DeclaringType), value);
|
||||
FieldInfo.SetValue(DeclaringInstance, value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ namespace UnityExplorer.UI.CacheObject
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetUserValue(object value)
|
||||
public override void TrySetUserValue(object value)
|
||||
{
|
||||
throw new NotImplementedException("TODO");
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace UnityExplorer.UI.CacheObject
|
||||
listCell.Image.color = ListIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor;
|
||||
}
|
||||
|
||||
public override void SetUserValue(object value)
|
||||
public override void TrySetUserValue(object value)
|
||||
{
|
||||
throw new NotImplementedException("TODO");
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityExplorer.Core.Runtime;
|
||||
using UnityExplorer.UI.CacheObject.Views;
|
||||
using UnityExplorer.UI.Inspectors;
|
||||
using UnityExplorer.UI.ObjectPool;
|
||||
@ -74,10 +75,11 @@ namespace UnityExplorer.UI.CacheObject
|
||||
SetValueFromSource(TryEvaluate());
|
||||
}
|
||||
|
||||
public override void SetUserValue(object value)
|
||||
public override void TrySetUserValue(object value)
|
||||
{
|
||||
// TODO unbox string, cast, etc
|
||||
|
||||
if (State == ValueState.String)
|
||||
ReflectionProvider.Instance.BoxStringToType(ref value, FallbackType);
|
||||
|
||||
TrySetValue(value);
|
||||
|
||||
Evaluate();
|
||||
|
@ -95,7 +95,13 @@ namespace UnityExplorer.UI.CacheObject
|
||||
|
||||
// Updating and applying values
|
||||
|
||||
public abstract void SetUserValue(object value);
|
||||
public void SetUserValue(object value)
|
||||
{
|
||||
value = value.TryCast(FallbackType);
|
||||
TrySetUserValue(value);
|
||||
}
|
||||
|
||||
public abstract void TrySetUserValue(object value);
|
||||
|
||||
public virtual void SetValueFromSource(object value)
|
||||
{
|
||||
|
@ -52,12 +52,11 @@ namespace UnityExplorer.UI.CacheObject
|
||||
try
|
||||
{
|
||||
bool _static = PropertyInfo.GetAccessors(true)[0].IsStatic;
|
||||
var target = _static ? null : Owner.Target.TryCast(DeclaringType);
|
||||
|
||||
if (HasArguments)
|
||||
PropertyInfo.SetValue(target, value, Evaluator.TryParseArguments());
|
||||
PropertyInfo.SetValue(DeclaringInstance, value, Evaluator.TryParseArguments());
|
||||
else
|
||||
PropertyInfo.SetValue(target, value, null);
|
||||
PropertyInfo.SetValue(DeclaringInstance, value, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user