// Bind a delegate to a named input axis. // Axis names are defined in the Editor, in the Input section of Edit->Project Settings... public void BindAxis(string axisName, AxisInputCallback callback) { if (IsDestroyedOrPendingKill) { throw new UnrealObjectDestroyedException("Trying to bind input axis on destroyed input component"); } if (null == callback) { throw new ArgumentNullException("callback"); } UnrealObject targetObj = callback.Target as UnrealObject; RegisterAxisInputCallback(NativeObject, targetObj != null ? targetObj.NativeObject : IntPtr.Zero, axisName, callback); }
// Bind a delegate directly to a specific float axis key, i.e. Keys.MouseX or Keys.Gamepad_LeftStick_Up public void BindAxisKey(Key axisKey, AxisInputCallback callback) { if (IsDestroyedOrPendingKill) { throw new UnrealObjectDestroyedException("Trying to bind input axis key on destroyed input component"); } if (null == callback) { throw new ArgumentNullException("callback"); } UnrealObject targetObj = callback.Target as UnrealObject; unsafe { byte *nativeKeyBuffer = stackalloc byte[InputChord.NativeDataSize]; axisKey.ToNative(new IntPtr(nativeKeyBuffer)); RegisterAxisKeyInputCallback(NativeObject, targetObj != null ? targetObj.NativeObject : IntPtr.Zero, nativeKeyBuffer, callback); } }
unsafe private extern static void RegisterAxisKeyInputCallback(IntPtr nativeComponentPointer, IntPtr nativeTargetObjectPointer, void *nativeAxisKey, AxisInputCallback callback);
private extern static void RegisterAxisInputCallback(IntPtr nativeComponentPointer, IntPtr nativeTargetObjectPointer, string axisName, AxisInputCallback callback);