mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-16 00:07:52 +08:00
2.0.2
* Added support for viewing Texture2D (and Sprite) from the Inspector, and exporting them to PNG * Fixed an issue with generic methods not showing their return value type * Fixed an issue where destroyed UnityEngine.Objects would cause issues in the inspector * Fixed an issue when caching a ValueCollection of a Dictionary (the generic argument for the Entry Type is the last arg, not the first as with other Enumerables)
This commit is contained in:
51
src/Unstrip/ImageConversion/ImageConversionUnstrip.cs
Normal file
51
src/Unstrip/ImageConversion/ImageConversionUnstrip.cs
Normal file
@ -0,0 +1,51 @@
|
||||
#if CPP
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnhollowerBaseLib;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
namespace Explorer.Unstrip.ImageConversion
|
||||
{
|
||||
public static class ImageConversionUnstrip
|
||||
{
|
||||
// byte[] ImageConversion.EncodeToPNG(this Texture2D image);
|
||||
|
||||
public static byte[] EncodeToPNG(this Texture2D tex)
|
||||
{
|
||||
return EncodeToPNG_iCall(tex.Pointer);
|
||||
}
|
||||
|
||||
internal delegate byte[] EncodeToPNG_delegate(IntPtr tex);
|
||||
internal static EncodeToPNG_delegate EncodeToPNG_iCall =
|
||||
IL2CPP.ResolveICall<EncodeToPNG_delegate>("UnityEngine.ImageConversion::EncodeToPNG");
|
||||
|
||||
// bool ImageConversion.LoadImage(this Texture2D tex, byte[] data, bool markNonReadable);
|
||||
|
||||
public static bool LoadImage(this Texture2D tex, byte[] data, bool markNonReadable)
|
||||
{
|
||||
return LoadImage_iCall(tex.Pointer, data, markNonReadable);
|
||||
}
|
||||
|
||||
internal delegate bool LoadImage_delegate(IntPtr tex, byte[] data, bool markNonReadable);
|
||||
internal static LoadImage_delegate LoadImage_iCall =
|
||||
IL2CPP.ResolveICall<LoadImage_delegate>("UnityEngine.ImageConversion::LoadImage");
|
||||
|
||||
// Helper for LoadImage
|
||||
|
||||
public static bool LoadImage(this Texture2D tex, string filePath, bool markNonReadable)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = File.ReadAllBytes(filePath);
|
||||
return tex.LoadImage(data, markNonReadable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -5,37 +5,35 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using UnhollowerBaseLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Explorer.Unstrip.Scene
|
||||
namespace Explorer.Unstrip.Scenes
|
||||
{
|
||||
public class SceneUnstrip
|
||||
{
|
||||
internal delegate void getRootSceneObjects(int handle, IntPtr list);
|
||||
internal static getRootSceneObjects getRootSceneObjects_iCall =
|
||||
IL2CPP.ResolveICall<getRootSceneObjects>("UnityEngine.SceneManagement.Scene::GetRootGameObjectsInternal");
|
||||
|
||||
public static void GetRootGameObjects_Internal(UnityEngine.SceneManagement.Scene scene, IntPtr list)
|
||||
{
|
||||
getRootSceneObjects_iCall(scene.handle, list);
|
||||
}
|
||||
|
||||
public static GameObject[] GetRootSceneObjects(UnityEngine.SceneManagement.Scene scene)
|
||||
//Scene.GetRootGameObjects();
|
||||
public static GameObject[] GetRootGameObjects(Scene scene)
|
||||
{
|
||||
var list = new Il2CppSystem.Collections.Generic.List<GameObject>(GetRootCount_Internal(scene));
|
||||
|
||||
GetRootGameObjects_Internal(scene, list.Pointer);
|
||||
GetRootGameObjectsInternal_iCall(scene.handle, list.Pointer);
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
internal delegate int getRootCount(int handle);
|
||||
internal static getRootCount getRootCount_iCall =
|
||||
IL2CPP.ResolveICall<getRootCount>("UnityEngine.SceneManagement.Scene::GetRootCountInternal");
|
||||
internal delegate void GetRootGameObjectsInternal_delegate(int handle, IntPtr list);
|
||||
internal static GetRootGameObjectsInternal_delegate GetRootGameObjectsInternal_iCall =
|
||||
IL2CPP.ResolveICall<GetRootGameObjectsInternal_delegate>("UnityEngine.SceneManagement.Scene::GetRootGameObjectsInternal");
|
||||
|
||||
//Scene.rootCount;
|
||||
public static int GetRootCount_Internal(UnityEngine.SceneManagement.Scene scene)
|
||||
{
|
||||
return getRootCount_iCall(scene.handle);
|
||||
return GetRootCountInternal_iCall(scene.handle);
|
||||
}
|
||||
|
||||
internal delegate int GetRootCountInternal_delegate(int handle);
|
||||
internal static GetRootCountInternal_delegate GetRootCountInternal_iCall =
|
||||
IL2CPP.ResolveICall<GetRootCountInternal_delegate>("UnityEngine.SceneManagement.Scene::GetRootCountInternal");
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user