private void InputAction_canceled(InputAction.CallbackContext obj) { // could be faster if it didn't have to search a dictionary? UnityInputSystemAction action = ActionDictionary[obj.action]; action.SetValue(obj.action.ReadValueAsObject()); action.FireCancelEvent(); }
private void Inputaction_performed(InputAction.CallbackContext obj) { // could be faster if it didn't have to search a dictionary? UnityInputSystemAction action = ActionDictionary[obj.action]; action.SetValue(obj.action.ReadValueAsObject()); // Fire Event on UnityAction action.FirePerformedEvent(); }
public void FireStartedEvent() { //create copy of action so it can't change while handling event var action = new UnityInputSystemAction(this.name); action.Started = true; action.SetValue(value); foreach (var del in sortedDelegates) { if (del.Started == true) { del.Invoke(action); } } }
/// <summary> /// Subscribe to IAction performed without returning IAction. /// Returns true if succesful and false if Action doesn't exist. /// </summary> public bool SubscribeToActionPerformed(InputAction action, UnityInputSystemAction.ActionDelegate func, bool AddWhenNotExisting = false) { if (!ActionDictionary.ContainsKey(action)) { if (AddWhenNotExisting) { UnityInputSystemAction newAction = new UnityInputSystemAction(action.name); ActionDictionary.Add(action, newAction); newAction.SubscribePerformed(func); } else { return(false); } } ActionDictionary[action].SubscribePerformed(func); return(true); }
private void Awake() { instance = this; actions = new Netherlands3DInputActions(); actionMaps = actions.asset; foreach (UnityEngine.InputSystem.InputActionMap map in actionMaps.actionMaps) { UnityActionMap unityMap = new UnityActionMap(map); foreach (var inputAction in map) { UnityInputSystemAction tmp = new UnityInputSystemAction(inputAction.name); ActionDictionary.Add(inputAction, tmp); inputAction.performed += Inputaction_performed; inputAction.canceled += InputAction_canceled; inputAction.started += Inputaction_started; unityMap.boundActions.Add(ActionDictionary[inputAction]); ActionHandler.actions.StreetView.Disable(); } unityActionMaps.Add(unityMap); } }