mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-18 06:57:46 +08:00
54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
![]() |
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|