mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-22 16:42:38 +08:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
3b4ea31b50 | |||
ad7b05f721 | |||
852ca8e9eb | |||
7386eca0c2 | |||
97325a5f3a | |||
82e52de557 |
@ -16,7 +16,7 @@ namespace UnityExplorer
|
||||
public class ExplorerCore
|
||||
{
|
||||
public const string NAME = "UnityExplorer";
|
||||
public const string VERSION = "3.1.0";
|
||||
public const string VERSION = "3.1.3";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.unityexplorer";
|
||||
public const string EXPLORER_FOLDER = @"Mods\UnityExplorer";
|
||||
|
@ -15,6 +15,16 @@ namespace UnityExplorer.Helpers
|
||||
private static MethodInfo EncodeToPNGMethod => m_encodeToPNGMethod ?? GetEncodeToPNGMethod();
|
||||
private static MethodInfo m_encodeToPNGMethod;
|
||||
|
||||
public static byte[] EncodeToPNGSafe(this Texture2D tex)
|
||||
{
|
||||
var method = EncodeToPNGMethod;
|
||||
|
||||
if (method.IsStatic)
|
||||
return (byte[])method.Invoke(null, new object[] { tex });
|
||||
else
|
||||
return (byte[])method.Invoke(tex, new object[0]);
|
||||
}
|
||||
|
||||
private static MethodInfo GetEncodeToPNGMethod()
|
||||
{
|
||||
if (ReflectionHelpers.GetTypeByName("UnityEngine.ImageConversion") is Type imageConversion)
|
||||
|
@ -111,8 +111,11 @@ namespace UnityExplorer.Inspectors.GameObjects
|
||||
internal static void OnCompToggleClicked(int index, bool value)
|
||||
{
|
||||
var comp = s_compShortlist[index];
|
||||
|
||||
#if CPP
|
||||
comp.TryCast<Behaviour>().enabled = value;
|
||||
#else
|
||||
(comp as Behaviour).enabled = value;
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void OnCompListObjectClicked(int index)
|
||||
|
@ -272,7 +272,14 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
if (File.Exists(path))
|
||||
File.Delete(path);
|
||||
|
||||
var data = tex.EncodeToPNG();
|
||||
if (!tex.IsReadable())
|
||||
tex = Texture2DHelpers.ForceReadTexture(tex);
|
||||
#if CPP
|
||||
byte[] data = tex.EncodeToPNG();
|
||||
#else
|
||||
byte[] data = tex.EncodeToPNGSafe();
|
||||
#endif
|
||||
|
||||
File.WriteAllBytes(path, data);
|
||||
}
|
||||
});
|
||||
|
@ -87,12 +87,6 @@ namespace UnityExplorer.UI
|
||||
new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_visible))),
|
||||
true);
|
||||
|
||||
#if BIE
|
||||
#if CPP
|
||||
// temporarily disabling this patch in BepInEx il2cpp as it's causing a crash in some games.
|
||||
return;
|
||||
#endif
|
||||
#endif
|
||||
TryPatch(typeof(EventSystem),
|
||||
"current",
|
||||
new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_EventSystem_set_current))),
|
||||
@ -164,9 +158,22 @@ namespace UnityExplorer.UI
|
||||
|
||||
public static void SetEventSystem()
|
||||
{
|
||||
// temp disabled for new InputSystem
|
||||
if (InputManager.CurrentType == InputType.InputSystem)
|
||||
return;
|
||||
|
||||
// Disable current event system object
|
||||
if (m_lastEventSystem || EventSystem.current)
|
||||
{
|
||||
if (!m_lastEventSystem)
|
||||
m_lastEventSystem = EventSystem.current;
|
||||
|
||||
//ExplorerCore.Log("Disabling current event system...");
|
||||
m_lastEventSystem.enabled = false;
|
||||
//m_lastEventSystem.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Set to our current system
|
||||
m_settingEventSystem = true;
|
||||
EventSystem.current = UIManager.EventSys;
|
||||
InputManager.ActivateUIModule();
|
||||
@ -180,6 +187,9 @@ namespace UnityExplorer.UI
|
||||
|
||||
if (m_lastEventSystem)
|
||||
{
|
||||
m_lastEventSystem.enabled = true;
|
||||
//m_lastEventSystem.gameObject.SetActive(true);
|
||||
|
||||
m_settingEventSystem = true;
|
||||
EventSystem.current = m_lastEventSystem;
|
||||
m_lastInputModule?.ActivateModule();
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
//using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
@ -51,8 +50,6 @@ namespace UnityExplorer.UI.Modules
|
||||
private SceneFilter m_sceneFilter;
|
||||
private ChildFilter m_childFilter;
|
||||
|
||||
internal bool m_isStaticClassSearching;
|
||||
|
||||
// ui elements
|
||||
|
||||
private Text m_resultCountText;
|
||||
@ -248,12 +245,15 @@ namespace UnityExplorer.UI.Modules
|
||||
UnityObjectSearch();
|
||||
|
||||
RefreshResultList();
|
||||
|
||||
if (m_results.Length > 0)
|
||||
m_resultCountText.text = $"{m_results.Length} Results";
|
||||
else
|
||||
m_resultCountText.text = "No results...";
|
||||
}
|
||||
|
||||
internal void StaticClassSearch()
|
||||
{
|
||||
m_isStaticClassSearching = true;
|
||||
|
||||
var list = new List<Type>();
|
||||
|
||||
var nameFilter = "";
|
||||
@ -274,16 +274,30 @@ namespace UnityExplorer.UI.Modules
|
||||
m_results = list.ToArray();
|
||||
}
|
||||
|
||||
internal string[] s_instanceNames = new string[]
|
||||
{
|
||||
"m_instance",
|
||||
"m_Instance",
|
||||
"s_instance",
|
||||
"s_Instance",
|
||||
"_instance",
|
||||
"_Instance",
|
||||
"instance",
|
||||
"Instance",
|
||||
"<Instance>k__BackingField",
|
||||
"<instance>k__BackingField",
|
||||
};
|
||||
|
||||
private void SingletonSearch()
|
||||
{
|
||||
m_isStaticClassSearching = false;
|
||||
|
||||
var instances = new List<object>();
|
||||
|
||||
var nameFilter = "";
|
||||
if (!string.IsNullOrEmpty(m_nameInput.text))
|
||||
nameFilter = m_nameInput.text.ToLower();
|
||||
|
||||
var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
|
||||
|
||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
// All non-static classes
|
||||
@ -293,31 +307,36 @@ namespace UnityExplorer.UI.Modules
|
||||
{
|
||||
if (!string.IsNullOrEmpty(nameFilter) && !type.FullName.ToLower().Contains(nameFilter))
|
||||
continue;
|
||||
|
||||
// First look for an "Instance" Property
|
||||
if (type.GetProperty("Instance", ReflectionHelpers.CommonFlags) is PropertyInfo pi
|
||||
&& pi.CanRead
|
||||
&& pi.GetGetMethod(true).IsStatic)
|
||||
#if CPP
|
||||
// Only look for Properties in IL2CPP, not for Mono.
|
||||
PropertyInfo pi;
|
||||
foreach (var name in s_instanceNames)
|
||||
{
|
||||
var instance = pi.GetValue(null, null);
|
||||
if (instance != null)
|
||||
instances.Add(instance);
|
||||
pi = type.GetProperty(name, flags);
|
||||
if (pi != null)
|
||||
{
|
||||
var instance = pi.GetValue(null, null);
|
||||
if (instance != null)
|
||||
{
|
||||
instances.Add(instance);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
// Look for a typical Instance backing field.
|
||||
FieldInfo fi;
|
||||
foreach (var name in s_instanceNames)
|
||||
{
|
||||
// Otherwise, look for a typical Instance backing field.
|
||||
FieldInfo fi;
|
||||
fi = type.GetField("m_instance", ReflectionHelpers.CommonFlags);
|
||||
if (fi == null)
|
||||
fi = type.GetField("s_instance", ReflectionHelpers.CommonFlags);
|
||||
if (fi == null)
|
||||
fi = type.GetField("_instance", ReflectionHelpers.CommonFlags);
|
||||
if (fi == null)
|
||||
fi = type.GetField("instance", ReflectionHelpers.CommonFlags);
|
||||
|
||||
if (fi != null && fi.IsStatic)
|
||||
fi = type.GetField(name, flags);
|
||||
if (fi != null)
|
||||
{
|
||||
var instance = fi.GetValue(null);
|
||||
if (instance != null)
|
||||
{
|
||||
instances.Add(instance);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -330,8 +349,6 @@ namespace UnityExplorer.UI.Modules
|
||||
|
||||
internal void UnityObjectSearch()
|
||||
{
|
||||
m_isStaticClassSearching = false;
|
||||
|
||||
Type searchType = null;
|
||||
switch (m_context)
|
||||
{
|
||||
@ -444,11 +461,6 @@ namespace UnityExplorer.UI.Modules
|
||||
}
|
||||
|
||||
m_results = results.ToArray();
|
||||
|
||||
if (m_results.Length > 0)
|
||||
m_resultCountText.text = $"{m_results.Length} Results";
|
||||
else
|
||||
m_resultCountText.text = "No results...";
|
||||
}
|
||||
|
||||
private void OnResultPageTurn()
|
||||
|
@ -45,7 +45,6 @@ namespace UnityExplorer.UI
|
||||
SceneExplorer.Instance?.OnSceneChange();
|
||||
SearchPage.Instance?.OnSceneChange();
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
MainMenu.Instance?.Update();
|
||||
@ -53,12 +52,9 @@ namespace UnityExplorer.UI
|
||||
if (EventSys)
|
||||
{
|
||||
if (EventSystem.current != EventSys)
|
||||
{
|
||||
ForceUnlockCursor.SetEventSystem();
|
||||
}
|
||||
|
||||
#if CPP
|
||||
// Fix for games which override the InputModule pointer events (eg, VRChat)
|
||||
// Some IL2CPP games behave weird with multiple UI Input Systems, some fixes for them.
|
||||
var evt = InputManager.InputPointerEvent;
|
||||
if (evt != null)
|
||||
{
|
||||
@ -69,9 +65,7 @@ namespace UnityExplorer.UI
|
||||
}
|
||||
|
||||
if (PanelDragger.Instance != null)
|
||||
{
|
||||
PanelDragger.Instance.Update();
|
||||
}
|
||||
|
||||
for (int i = 0; i < SliderScrollbar.Instances.Count; i++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user