mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 13:57:31 +08:00
Fix InputSystem for IL2CPP
This commit is contained in:
parent
3628f3db31
commit
3762d14bdb
@ -163,12 +163,14 @@ namespace UnityExplorer.Core.Input
|
||||
|
||||
var assetType = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputActionAsset");
|
||||
m_newInputModule = RuntimeProvider.Instance.AddComponent<BaseInputModule>(UIManager.CanvasRoot, TInputSystemUIInputModule);
|
||||
var asset = RuntimeProvider.Instance.CreateScriptable(assetType);
|
||||
var asset = RuntimeProvider.Instance.CreateScriptable(assetType)
|
||||
.Cast(assetType);
|
||||
|
||||
inputExtensions = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputActionSetupExtensions");
|
||||
|
||||
var addMap = inputExtensions.GetMethod("AddActionMap", new Type[] { assetType, typeof(string) });
|
||||
var map = addMap.Invoke(null, new object[] { asset, "UI" });
|
||||
var map = addMap.Invoke(null, new object[] { asset, "UI" })
|
||||
.Cast(ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputActionMap"));
|
||||
|
||||
CreateAction(map, "point", new[] { "<Mouse>/position" }, "point");
|
||||
CreateAction(map, "click", new[] { "<Mouse>/leftButton" }, "leftClick");
|
||||
@ -186,23 +188,25 @@ namespace UnityExplorer.Core.Input
|
||||
|
||||
private void CreateAction(object map, string actionName, string[] bindings, string propertyName)
|
||||
{
|
||||
var inputActionType = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputAction");
|
||||
var addAction = inputExtensions.GetMethod("AddAction");
|
||||
var pointAction = addAction.Invoke(null, new object[] { map, actionName, default, null, null, null, null, null });
|
||||
var action = addAction.Invoke(null, new object[] { map, actionName, default, null, null, null, null, null })
|
||||
.Cast(inputActionType);
|
||||
|
||||
var inputActionType = pointAction.GetType();
|
||||
var addBinding = inputExtensions.GetMethod("AddBinding",
|
||||
new Type[] { inputActionType, typeof(string), typeof(string), typeof(string), typeof(string) });
|
||||
|
||||
foreach (string binding in bindings)
|
||||
addBinding.Invoke(null, new object[] { pointAction, binding, null, null, null });
|
||||
addBinding.Invoke(null, new object[] { action.Cast(inputActionType), binding, null, null, null });
|
||||
|
||||
var inputRef = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputActionReference")
|
||||
.GetMethod("Create")
|
||||
.Invoke(null, new object[] { pointAction });
|
||||
var refType = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputActionReference");
|
||||
var inputRef = refType.GetMethod("Create")
|
||||
.Invoke(null, new object[] { action })
|
||||
.Cast(refType);
|
||||
|
||||
TInputSystemUIInputModule
|
||||
.GetProperty(propertyName)
|
||||
.SetValue(m_newInputModule, inputRef, null);
|
||||
.SetValue(m_newInputModule.Cast(TInputSystemUIInputModule), inputRef, null);
|
||||
}
|
||||
|
||||
public void ActivateModule()
|
||||
|
Loading…
x
Reference in New Issue
Block a user