@@ -163,12 +163,14 @@ public void AddUIInputModule()
163
163
164
164
var assetType = ReflectionUtility . GetTypeByName ( "UnityEngine.InputSystem.InputActionAsset" ) ;
165
165
m_newInputModule = RuntimeProvider . Instance . AddComponent < BaseInputModule > ( UIManager . CanvasRoot , TInputSystemUIInputModule ) ;
166
- var asset = RuntimeProvider . Instance . CreateScriptable ( assetType ) ;
166
+ var asset = RuntimeProvider . Instance . CreateScriptable ( assetType )
167
+ . Cast ( assetType ) ;
167
168
168
169
inputExtensions = ReflectionUtility . GetTypeByName ( "UnityEngine.InputSystem.InputActionSetupExtensions" ) ;
169
170
170
171
var addMap = inputExtensions . GetMethod ( "AddActionMap" , new Type [ ] { assetType , typeof ( string ) } ) ;
171
- var map = addMap . Invoke ( null , new object [ ] { asset , "UI" } ) ;
172
+ var map = addMap . Invoke ( null , new object [ ] { asset , "UI" } )
173
+ . Cast ( ReflectionUtility . GetTypeByName ( "UnityEngine.InputSystem.InputActionMap" ) ) ;
172
174
173
175
CreateAction ( map , "point" , new [ ] { "<Mouse>/position" } , "point" ) ;
174
176
CreateAction ( map , "click" , new [ ] { "<Mouse>/leftButton" } , "leftClick" ) ;
@@ -186,23 +188,25 @@ public void AddUIInputModule()
186
188
187
189
private void CreateAction ( object map , string actionName , string [ ] bindings , string propertyName )
188
190
{
191
+ var inputActionType = ReflectionUtility . GetTypeByName ( "UnityEngine.InputSystem.InputAction" ) ;
189
192
var addAction = inputExtensions . GetMethod ( "AddAction" ) ;
190
- var pointAction = addAction . Invoke ( null , new object [ ] { map , actionName , default , null , null , null , null , null } ) ;
193
+ var action = addAction . Invoke ( null , new object [ ] { map , actionName , default , null , null , null , null , null } )
194
+ . Cast ( inputActionType ) ;
191
195
192
- var inputActionType = pointAction . GetType ( ) ;
193
196
var addBinding = inputExtensions . GetMethod ( "AddBinding" ,
194
197
new Type [ ] { inputActionType , typeof ( string ) , typeof ( string ) , typeof ( string ) , typeof ( string ) } ) ;
195
198
196
199
foreach ( string binding in bindings )
197
- addBinding . Invoke ( null , new object [ ] { pointAction , binding , null , null , null } ) ;
200
+ addBinding . Invoke ( null , new object [ ] { action . Cast ( inputActionType ) , binding , null , null , null } ) ;
198
201
199
- var inputRef = ReflectionUtility . GetTypeByName ( "UnityEngine.InputSystem.InputActionReference" )
200
- . GetMethod ( "Create" )
201
- . Invoke ( null , new object [ ] { pointAction } ) ;
202
+ var refType = ReflectionUtility . GetTypeByName ( "UnityEngine.InputSystem.InputActionReference" ) ;
203
+ var inputRef = refType . GetMethod ( "Create" )
204
+ . Invoke ( null , new object [ ] { action } )
205
+ . Cast ( refType ) ;
202
206
203
207
TInputSystemUIInputModule
204
208
. GetProperty ( propertyName )
205
- . SetValue ( m_newInputModule , inputRef , null ) ;
209
+ . SetValue ( m_newInputModule . Cast ( TInputSystemUIInputModule ) , inputRef , null ) ;
206
210
}
207
211
208
212
public void ActivateModule ( )
0 commit comments