mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-22 16:42:38 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
adfa29e63c | |||
3ffdcea73b | |||
dfd55260a8 | |||
29c78dc5a6 |
@ -12,6 +12,8 @@ namespace UnityExplorer.Core.Input
|
||||
{
|
||||
public InputSystem()
|
||||
{
|
||||
SetupSupportedDevices();
|
||||
|
||||
m_kbCurrentProp = TKeyboard.GetProperty("current");
|
||||
m_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
|
||||
|
||||
@ -32,7 +34,37 @@ namespace UnityExplorer.Core.Input
|
||||
.GetMethod("ReadValue");
|
||||
}
|
||||
|
||||
#region reflection cache
|
||||
internal static void SetupSupportedDevices()
|
||||
{
|
||||
try
|
||||
{
|
||||
// typeof(InputSystem)
|
||||
Type TInputSystem = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputSystem");
|
||||
// InputSystem.settings
|
||||
var settings = TInputSystem.GetProperty("settings", BindingFlags.Public | BindingFlags.Static).GetValue(null, null);
|
||||
// typeof(InputSettings)
|
||||
Type TSettings = settings.GetActualType();
|
||||
// InputSettings.supportedDevices
|
||||
PropertyInfo supportedProp = TSettings.GetProperty("supportedDevices", BindingFlags.Public | BindingFlags.Instance);
|
||||
var supportedDevices = supportedProp.GetValue(settings, null);
|
||||
// An empty supportedDevices list means all devices are supported.
|
||||
#if CPP
|
||||
// weird hack for il2cpp, use the implicit operator and cast Il2CppStringArray to ReadOnlyArray<string>
|
||||
var args = new object[] { new UnhollowerBaseLib.Il2CppStringArray(0) };
|
||||
var method = supportedDevices.GetActualType().GetMethod("op_Implicit", BindingFlags.Static | BindingFlags.Public);
|
||||
supportedProp.SetValue(settings, method.Invoke(null, args), null);
|
||||
#else
|
||||
supportedProp.SetValue(settings, Activator.CreateInstance(supportedDevices.GetActualType(), new object[] { new string[0] }), null);
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExplorerCore.LogWarning($"Exception setting up InputSystem.settings.supportedDevices list!");
|
||||
ExplorerCore.Log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
#region reflection cache
|
||||
|
||||
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
|
||||
private static Type m_tKeyboard;
|
||||
@ -73,7 +105,7 @@ namespace UnityExplorer.Core.Input
|
||||
private static object m_scrollInfo;
|
||||
private static PropertyInfo m_scrollDeltaProp;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public Vector2 MousePosition
|
||||
{
|
||||
@ -138,6 +170,8 @@ namespace UnityExplorer.Core.Input
|
||||
|
||||
public bool GetMouseButtonDown(int btn)
|
||||
{
|
||||
if (CurrentMouse == null)
|
||||
return false;
|
||||
switch (btn)
|
||||
{
|
||||
case 0: return (bool)m_btnWasPressedProp.GetValue(LeftMouseButton, null);
|
||||
@ -149,6 +183,8 @@ namespace UnityExplorer.Core.Input
|
||||
|
||||
public bool GetMouseButton(int btn)
|
||||
{
|
||||
if (CurrentMouse == null)
|
||||
return false;
|
||||
switch (btn)
|
||||
{
|
||||
case 0: return (bool)m_btnIsPressedProp.GetValue(LeftMouseButton, null);
|
||||
|
@ -20,7 +20,7 @@ namespace UnityExplorer
|
||||
public static class ExplorerCore
|
||||
{
|
||||
public const string NAME = "UnityExplorer";
|
||||
public const string VERSION = "4.1.9";
|
||||
public const string VERSION = "4.1.10";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.unityexplorer";
|
||||
|
||||
|
@ -414,33 +414,29 @@ namespace UnityExplorer.UI
|
||||
|
||||
private static void LoadBundle()
|
||||
{
|
||||
AssetBundle bundle = null;
|
||||
AssetBundle bundle;
|
||||
try
|
||||
{
|
||||
// Get the Unity version (without the 'f' suffix).
|
||||
// I'm not sure if Unity always includes the 'f' suffix.
|
||||
int len;
|
||||
if (Application.unityVersion.Contains("f"))
|
||||
len = Application.unityVersion.LastIndexOf("f");
|
||||
else
|
||||
len = Application.unityVersion.Length;
|
||||
Version version = new Version(Application.unityVersion.Substring(0, len));
|
||||
// Get the Major and Minor of the Unity version
|
||||
var split = Application.unityVersion.Split('.');
|
||||
int major = int.Parse(split[0]);
|
||||
int minor = int.Parse(split[1]);
|
||||
|
||||
// Use appropriate AssetBundle for Unity version
|
||||
// >= 2017.3
|
||||
if (version.Major > 2017 || (version.Major == 2017 && version.Minor >= 3))
|
||||
if (major > 2017 || (major == 2017 && minor >= 3))
|
||||
bundle = LoadBundle("modern");
|
||||
// 5.6.0 to 2017.3
|
||||
else if (version.Major == 2017 || (version.Major == 5 && version.Minor >= 6))
|
||||
else if (major == 2017 || (major == 5 && minor >= 6))
|
||||
bundle = LoadBundle("legacy.5.6");
|
||||
// < 5.6.0
|
||||
else
|
||||
bundle = LoadBundle("legacy");
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch
|
||||
{
|
||||
ExplorerCore.LogWarning($"Exception loading Explorer AssetBundle!");
|
||||
ExplorerCore.Log(ex);
|
||||
ExplorerCore.LogWarning($"Exception parsing Unity version, falling back to old AssetBundle load method...");
|
||||
bundle = LoadBundle("modern") ?? LoadBundle("legacy.5.6") ?? LoadBundle("legacy");
|
||||
}
|
||||
|
||||
AssetBundle LoadBundle(string id)
|
||||
|
Reference in New Issue
Block a user