mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-24 01:12:41 +08:00
Finished scene explorer, lots of cleanups. Inspector and Search left now.
This commit is contained in:
@ -1,11 +1,8 @@
|
||||
#if CPP
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ExplorerBeta.Helpers
|
||||
{
|
||||
@ -17,18 +14,16 @@ namespace ExplorerBeta.Helpers
|
||||
public static T GetICall<T>(string iCallName) where T : Delegate
|
||||
{
|
||||
if (iCallCache.ContainsKey(iCallName))
|
||||
{
|
||||
return (T)iCallCache[iCallName];
|
||||
}
|
||||
|
||||
var ptr = il2cpp_resolve_icall(iCallName);
|
||||
IntPtr ptr = il2cpp_resolve_icall(iCallName);
|
||||
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
throw new MissingMethodException($"Could not resolve internal call by name '{iCallName}'!");
|
||||
}
|
||||
|
||||
var iCall = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
|
||||
Delegate iCall = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
|
||||
iCallCache.Add(iCallName, iCall);
|
||||
|
||||
return (T)iCall;
|
||||
|
@ -22,10 +22,10 @@ namespace ExplorerBeta.Helpers
|
||||
|
||||
#if CPP
|
||||
public static ILType GameObjectType => Il2CppType.Of<GameObject>();
|
||||
public static ILType TransformType => Il2CppType.Of<Transform>();
|
||||
public static ILType ObjectType => Il2CppType.Of<UnityEngine.Object>();
|
||||
public static ILType ComponentType => Il2CppType.Of<Component>();
|
||||
public static ILType BehaviourType => Il2CppType.Of<Behaviour>();
|
||||
public static ILType TransformType => Il2CppType.Of<Transform>();
|
||||
public static ILType ObjectType => Il2CppType.Of<UnityEngine.Object>();
|
||||
public static ILType ComponentType => Il2CppType.Of<Component>();
|
||||
public static ILType BehaviourType => Il2CppType.Of<Behaviour>();
|
||||
#else
|
||||
public static Type GameObjectType => typeof(GameObject);
|
||||
public static Type TransformType => typeof(Transform);
|
||||
@ -40,10 +40,14 @@ namespace ExplorerBeta.Helpers
|
||||
public static object Il2CppCast(object obj, Type castTo)
|
||||
{
|
||||
if (!(obj is Il2CppSystem.Object ilObj))
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (!typeof(Il2CppSystem.Object).IsAssignableFrom(castTo))
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
IntPtr castToPtr;
|
||||
if (!ClassPointers.ContainsKey(castTo))
|
||||
@ -61,9 +65,11 @@ namespace ExplorerBeta.Helpers
|
||||
}
|
||||
|
||||
if (castToPtr == IntPtr.Zero)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
var classPtr = il2cpp_object_get_class(ilObj.Pointer);
|
||||
IntPtr classPtr = il2cpp_object_get_class(ilObj.Pointer);
|
||||
|
||||
if (!il2cpp_class_is_assignable_from(castToPtr, classPtr))
|
||||
return obj;
|
||||
@ -100,7 +106,8 @@ namespace ExplorerBeta.Helpers
|
||||
|
||||
public static Type GetActualType(object obj)
|
||||
{
|
||||
if (obj == null) return null;
|
||||
if (obj == null)
|
||||
return null;
|
||||
|
||||
#if CPP
|
||||
// Need to use GetIl2CppType for Il2CppSystem Objects
|
||||
@ -124,7 +131,7 @@ namespace ExplorerBeta.Helpers
|
||||
|
||||
public static Type[] GetAllBaseTypes(Type type)
|
||||
{
|
||||
var list = new List<Type>();
|
||||
List<Type> list = new List<Type>();
|
||||
|
||||
while (type != null)
|
||||
{
|
||||
@ -139,11 +146,14 @@ namespace ExplorerBeta.Helpers
|
||||
{
|
||||
#if CPP
|
||||
#if ML
|
||||
var path = $@"MelonLoader\Managed\{module}.dll";
|
||||
string path = $@"MelonLoader\Managed\{module}.dll";
|
||||
#else
|
||||
var path = $@"BepInEx\unhollowed\{module}.dll";
|
||||
#endif
|
||||
if (!File.Exists(path)) return false;
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
#if CPP
|
||||
using ExplorerBeta.Unstrip.ImageConversion;
|
||||
#endif
|
||||
@ -61,9 +57,7 @@ namespace ExplorerBeta.Helpers
|
||||
Color[] pixels;
|
||||
|
||||
if (!orig.IsReadable())
|
||||
{
|
||||
orig = ForceReadTexture(orig);
|
||||
}
|
||||
|
||||
pixels = orig.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
||||
|
||||
@ -77,7 +71,7 @@ namespace ExplorerBeta.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
var origFilter = tex.filterMode;
|
||||
FilterMode origFilter = tex.filterMode;
|
||||
tex.filterMode = FilterMode.Point;
|
||||
|
||||
var rt = RenderTexture.GetTemporary(tex.width, tex.height, 0, RenderTextureFormat.ARGB32);
|
||||
@ -105,12 +99,10 @@ namespace ExplorerBeta.Helpers
|
||||
public static void SaveTextureAsPNG(Texture2D tex, string dir, string name, bool isDTXnmNormal = false)
|
||||
{
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
byte[] data;
|
||||
var savepath = dir + @"\" + name + ".png";
|
||||
string savepath = dir + @"\" + name + ".png";
|
||||
|
||||
// Make sure we can EncodeToPNG it.
|
||||
if (tex.format != TextureFormat.ARGB32 || !tex.IsReadable())
|
||||
@ -154,12 +146,12 @@ namespace ExplorerBeta.Helpers
|
||||
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
Color c = colors[i];
|
||||
var c = colors[i];
|
||||
|
||||
c.r = c.a * 2 - 1; // red <- alpha
|
||||
c.g = c.g * 2 - 1; // green is always the same
|
||||
|
||||
Vector2 rg = new Vector2(c.r, c.g); //this is the red-green vector
|
||||
var rg = new Vector2(c.r, c.g); //this is the red-green vector
|
||||
c.b = Mathf.Sqrt(1 - Mathf.Clamp01(Vector2.Dot(rg, rg))); //recalculate the blue channel
|
||||
|
||||
colors[i] = new Color(
|
||||
|
Reference in New Issue
Block a user