mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-05 04:42:54 +08:00
1.4.0
- Wrote the CacheObject class to replace MemberInfoHolder, resulting code is better perfomance and much easier to read. - Added pages to Object Reflection window, now limited to 20 members per page to improve performance further.
This commit is contained in:
53
src/CachedObjects/CacheGameObject.cs
Normal file
53
src/CachedObjects/CacheGameObject.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Explorer
|
||||
{
|
||||
public class CacheGameObject : CacheObject
|
||||
{
|
||||
private GameObject m_gameObject;
|
||||
|
||||
public CacheGameObject(object obj)
|
||||
{
|
||||
if (obj != null)
|
||||
m_gameObject = GetGameObject(obj);
|
||||
}
|
||||
|
||||
private GameObject GetGameObject(object obj)
|
||||
{
|
||||
if (obj is Il2CppSystem.Object ilObj)
|
||||
{
|
||||
var ilType = ilObj.GetIl2CppType();
|
||||
|
||||
if (ilType == ReflectionHelpers.GameObjectType || ilType == ReflectionHelpers.TransformType)
|
||||
{
|
||||
return ilObj.TryCast<GameObject>() ?? ilObj.TryCast<Transform>()?.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void DrawValue(Rect window, float width)
|
||||
{
|
||||
UIHelpers.GameobjButton(m_gameObject, null, false, width);
|
||||
}
|
||||
|
||||
public override void SetValue()
|
||||
{
|
||||
throw new NotImplementedException("TODO");
|
||||
}
|
||||
|
||||
public override void UpdateValue(object obj)
|
||||
{
|
||||
base.UpdateValue(obj);
|
||||
|
||||
m_gameObject = GetGameObject(Value);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user