private void Cancel() { ability.Disable(); Destroy(CreatedObject); CreatedObject = null; Interaction.Interact(transform.position); var create = (CreationInteraction)Interaction; create.createdObject = null; }
private void Cancel(InputAction.CallbackContext ctx) { Destroy(_createdObject); _ability.Disable(); _createdObject = null; //interaction.Interact(transform.position); var create = (CreationInteraction)interaction; create.createdObject = null; _movement["Ability"].Enable(); }
void OnDisable() { playerActions.Disable(); inventoryActions.Disable(); attackActions.Disable(); abilityActions.Disable(); }
private void OnDisable() { _showConsole = false; toggleDebugAction.Disable(); returnAction.Disable(); debugActionMap.Disable(); }
void Unload() { m_VrAnchorController.Unload(); if (!m_SkipVrInit) { // stop VR subsystems m_Manager.StopSubsystems(); // deinitialize VR m_Manager.DeinitializeLoader(); } // SteamVR might change the main FoV, so make sure to set it to the default m_ScreenModeCamera.fieldOfView = m_ScreenModeFieldOfView; // swap cameras m_ScreenModeCamera.gameObject.SetActive(true); if (m_ActionMap != null) { m_ActionMap.Disable(); } UIStateManager.projectStateChanged -= OnProjectStateDataChanged; }
private void OnDisable() { //movement.TryGetAction("Jump").performed -= Jump; //movement.TryGetAction("JumpHold").performed -= JumpHold; movement["Jump"].started -= StartJump; movement["Jump"].performed -= CancelJump; movement["Jump"].canceled -= CancelEarly; movement.Disable(); }
private void Initialize() { ability = input.Ability; movement = input.Player; ability.Disable(); movement.GetAction("Ability").performed += ctx => Interact(); ability.GetAction("Rotate").performed += ctx => Rotate(ctx.ReadValue <float>()); ability.GetAction("Place").performed += ctx => Place(); ability.GetAction("Cancel").performed += ctx => Cancel(); }
public static void SetActive(InputActionMap action, bool value) { if (value) { action.Enable(); } else { action.Disable(); } }
public static void SetActive(this InputActionMap that, bool enable) { if (enable) { that.Enable(); } else { that.Disable(); } }
private void OnDisable() { toggleLoggerAction.Disable(); loggerActionMap.Disable(); // If destroyed because already exists, don't need to de-register callback if (destroying) { return; } Application.logMessageReceived -= HandleLog; }
public void Open(bool show = true) { _show = show; animator.SetBool(VarShow, show); if (show) { _gameActionMap.Disable(); } else { _gameActionMap.Enable(); } }
public void OpenShop() { rangeGameObject.SetActive(true); otherDrivingActionMap.Disable(); meatSellingActionMap.Enable(); DrivingGameplayManager.Instance.CurrentControllerMode.VirtualCamera.Priority = 0; virtualCamera.Priority++; spawnedMeats = meatsSpawning.SpawnGivenMeats(GameManager.Instance.Player.Inventory.Meats); spawnedEarnedCash = new List <CashBehaviour>(); }
void SetSteering(VehicleType type) { switch (type) { case VehicleType.Drone: droneActionMap.Enable(); robotActionMap.Disable(); tractorActionMap.Disable(); break; case VehicleType.Tractor: droneActionMap.Disable(); robotActionMap.Disable(); tractorActionMap.Enable(); break; case VehicleType.Robot: droneActionMap.Disable(); robotActionMap.Enable(); tractorActionMap.Disable(); break; } }
void Awake() { m_InputActionAsset["Walk Mode Action"].performed += OnWalkStartPositionValidate; m_InputActionAsset["Switch Mode Action"].performed += OnSwitchMode; #if UNITY_ANDROID || UNITY_IOS m_InputActionAsset["Place Joystick Action"].performed += OnPlaceJoystick; #endif m_InputActionMap = m_InputActionAsset.FindActionMap("Walk"); m_InputActionMap.Disable(); m_OnScreenStick = m_LeftJoystick.GetComponentInChildren <OnScreenStick>(true); UIStateManager.stateChanged += OnStateDataChanged; UIStateManager.externalToolChanged += OnExternalToolChanged; m_JoystickImages = m_LeftJoystick.GetComponentsInChildren <Image>(); }
void ActivateFlyMode(bool moveCamera = true) { m_FPSController.SetActive(false); m_MainCamera.gameObject.SetActive(true); m_MainCamera.clearFlags = CameraClearFlags.Skybox; if (moveCamera) { m_FreeFlyCamera.SetMovePosition(m_FPSController.transform.position, m_FPSController.transform.rotation); } m_InputActionMap.Disable(); m_IsInit = false; }
void Awake() { #if UNITY_ANDROID || UNITY_IOS m_InputActionAsset["Place Joystick Action"].performed += OnPlaceJoystick; OrphanUIController.onBeginDrag += OnBeginDrag; OrphanUIController.onDrag += OnDrag; OrphanUIController.onEndDrag += OnCancel; #else m_InputActionAsset["Walk Mode Action"].started += OnBeginDrag; m_InputActionAsset["Walk Mode Action"].performed += OnDrag; m_InputActionAsset["Walk Mode Action"].canceled += OnCancel; #endif m_InputActionAsset["Walk Mode Action Tap"].canceled += OnCancel; m_InputActionMap = m_InputActionAsset.FindActionMap("Walk"); m_InputActionMap.Disable(); m_DisposeOnDestroy.Add(m_MeasureToolStateSelector = UISelectorFactory.createSelector <bool>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.toolState), OnMeasureToolToolChanged)); m_DisposeOnDestroy.Add(m_WalkModeEnableSelector = UISelectorFactory.createSelector <bool>(WalkModeContext.current, nameof(IWalkModeDataProvider.walkEnabled), OnWalkEnable)); m_DisposeOnDestroy.Add(m_WalkInstructionStateSelector = UISelectorFactory.createSelector <SetInstructionUIStateAction.InstructionUIState>(WalkModeContext.current, nameof(IWalkModeDataProvider.instructionUIState))); m_DisposeOnDestroy.Add(m_WalkInstructionSelector = UISelectorFactory.createSelector <IWalkInstructionUI>(WalkModeContext.current, nameof(IWalkModeDataProvider.instruction))); m_DisposeOnDestroy.Add(m_ScaleFactorSelector = UISelectorFactory.createSelector <float>(UIStateContext.current, nameof(IUIStateDisplayProvider <DisplayData> .display) + "." + nameof(IDisplayDataProvider.scaleFactor))); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <OpenDialogAction.DialogType>(UIStateContext.current, nameof(IDialogDataProvider.activeDialog), type => { m_CachedDialog = type; CheckJoystickAvailable(); })); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <OpenDialogAction.DialogType>(UIStateContext.current, nameof(IDialogDataProvider.activeSubDialog), type => { m_CachedSubDialog = type; CheckJoystickAvailable(); })); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <SetDialogModeAction.DialogMode>(UIStateContext.current, nameof(IDialogDataProvider.dialogMode), type => { m_CachedDialogMode = type; CheckJoystickAvailable(); })); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <SetActiveToolAction.ToolType>(ToolStateContext.current, nameof(IToolStateDataProvider.activeTool), type => { m_CachedActiveTool = type; CheckJoystickAvailable(); })); m_JoystickImages = m_LeftJoystick.GetComponentsInChildren <Image>(); }
void Start() { gasRemapButton.onClick.AddListener(delegate { RemapButtonClicked("Gas", gasRemapButton, gasMapIndex); }); brakeRemapButton.onClick.AddListener(delegate { RemapButtonClicked("Brake", brakeRemapButton, brakeMapIndex); }); fireRemapButton.onClick.AddListener(delegate { RemapButtonClicked("Fire", fireRemapButton, fireMapIndex); }); turretRemapButton.onClick.AddListener(delegate { RemapButtonClicked("Turret", turretRemapButton, turretMapIndex); }); okButton.onClick.AddListener(OkButtonClicked); // Set the first button to be selected so that // gamepad navigation can be performed. gasRemapButton.Select(); playerActionMap = tanksInputActions.GetActionMap("Player"); playerActionMap.Disable(); ResetButtonMappingTextValues(); }
void UpdateMapEnable(InputActionMap map, Func <bool> DoIsEnable) { if (map != null && DoIsEnable != null) { bool temp = DoIsEnable(); if (map.enabled != temp) { if (temp) { map.Enable(); } else { map.Disable(); } } } }
public void PauseGame() { IsPaused = !IsPaused; PauseMenu.SetActive(IsPaused); if (IsPaused) { previousTimeScale = Time.timeScale; Time.timeScale = 0f; fighterActionMap.Disable(); uiActionMap.Enable(); } else { Time.timeScale = previousTimeScale; fighterActionMap.Enable(); uiActionMap.Disable(); } }
public void Initialize() { input = GetComponent <PlayerInputSystem>(); _ability = input.Ability; _movement = input.Player; _ability.Disable(); _movement["Interact"].Disable(); _movement["Ability"].performed += ctx => Interact(); _ability["Place"].performed += Place; _ability["Cancel"].performed += Cancel; settings = input.Settings; if (_createdObject) { Destroy(_createdObject); _createdInteraction = null; _createdObject = null; } }
void ActivateFlyMode(bool moveCamera = true) { m_FPSController.SetActive(false); m_MainCamera.gameObject.SetActive(true); m_MainCamera.clearFlags = CameraClearFlags.Skybox; #if UNITY_IOS // Camera clearFlags is changed to CameraClearFlags.Nothing after one frame on iOS so need to set to Skybox in Coroutine StartCoroutine(SetCameraSkybox()); #endif if (moveCamera) { m_FreeFlyCamera.TransformTo(m_FPSController.transform); } m_InputActionMap.Disable(); m_InputActionAsset["Orbit Action"].Enable(); m_IsInit = false; }
void Unload() { m_VrAnchorController.Unload(); if (!m_SkipVrInit) { // stop VR subsystems m_Manager.StopSubsystems(); // deinitialize VR m_Manager.DeinitializeLoader(); } // swap cameras m_ScreenModeCamera.gameObject.SetActive(true); if (m_ActionMap != null) { m_ActionMap.Disable(); } }
public void ReturnToDriving() { otherDrivingActionMap.Enable(); meatSellingActionMap.Disable(); virtualCamera.Priority = 0; DrivingGameplayManager.Instance.CurrentControllerMode.VirtualCamera.Priority++; List <IItemJumpTo> itemsToGather = new List <IItemJumpTo>(); itemsToGather.AddRange(spawnedMeats); itemsToGather.AddRange(spawnedEarnedCash); itemsToGather.ForEach(item => item.JumpTo(playerVehicle.VehicleController.CenterOfMass.transform.position, false, () => Destroy(item.GameObject), true)); List <OnRouteToMeatShopNpcCharacterState> customersToInformAboutShopClosing = new List <OnRouteToMeatShopNpcCharacterState>(CustomersWalkingToShop); customersToInformAboutShopClosing.ForEach(customer => customer.OnMeatShopClosed()); CustomersWalkingToShop.Clear(); rangeGameObject.SetActive(false); }
public GenericDevice(InputDevice device) { m_Device = device; m_Controls = m_Device.allControls.ToList(); m_ControlTypes = m_Controls.Select(x => x.GetType()).Distinct().ToList(); m_UIType = UIType.Specialized; m_CaptureDetailedEventInfo = false; m_ActionMap = new InputActionMap(); m_ActionMap.Disable(); m_ActionMap.devices = new[] { device }; foreach (var c in m_Controls) { var action = m_ActionMap.AddAction(c.path, binding: c.path); action.performed += Action_performed; m_Actions[c] = new ActionData() { action = action }; } m_ActionMap.Enable(); }
/**** Combat controls ****/ public void OnModeSwitch() { pilotActionMap.Disable(); gunnerActionMap.Disable(); combatActionMap.Disable(); cabinActionMap.Enable(); if (mode == PlayerMode.GunnerMode) { Gunner.Shoot(false); Gunner.instance.player = null; } else if (mode == PlayerMode.PilotMode) { Pilot.instance.player = null; } mode = PlayerMode.CabinMode; //Debug.Log("Mode switched to Cabin"); ModeManager.ModeSwitch(this, PlayerMode.CabinMode); }
/// <summary> /// Tries to set a new active action map. /// If a new action map is set, returns true. /// </summary> /// <param name="actionMapName">Name of action map.</param> public bool TrySetActiveActionMap(string actionMapName) { if (actionMapName == null) { LogError("Cannot retrieve an InputActionMap when the provided map name is null"); return(false); } if (m_InputSettings == null) { LogError("Cannot set InputActionMap [" + actionMapName + "] as active because ECCInputSettings is null"); return(false); } if (m_InputSettings.InputActionAsset == null) { LogError("Cannot set InputActionMap [" + actionMapName + "] as active because no InputActionAsset is assigned"); return(false); } // Try to find action map. InputActionMap actionMap = m_InputSettings.InputActionAsset.FindActionMap(actionMapName); bool isValid = actionMap != null; if (!isValid) { LogError("InputActionMap [" + actionMapName + "] was not found"); } else // Update active action map and enable. { m_ActiveActionMap?.Disable(); // Disable current before enabling new. // Enable action map and set as active. actionMap.Enable(); m_ActiveActionMap = actionMap; } return(isValid); }
public void Actions_CanPerformPressInteraction_AndTriggerInteractionResetInCallback() { var keyboard = InputSystem.AddDevice <Keyboard>(); var asset = ScriptableObject.CreateInstance <InputActionAsset>(); var map1 = new InputActionMap("map1"); var map2 = new InputActionMap("map2"); asset.AddActionMap(map1); asset.AddActionMap(map2); var action1 = map1.AddAction("action1"); var action2 = map2.AddAction("action2"); // PressInteraction used to set some local state *after* trigger callbacks. This meant that if the // callback triggered a Reset() call, PressInteraction would then overwrite state from the reset. action1.AddBinding("<Keyboard>/a", interactions: "press(behavior=0)"); action2.AddBinding("<Keyboard>/b", interactions: "press(behavior=0)"); action1.performed += _ => { map1.Disable(); map2.Enable(); }; action2.performed += _ => { map2.Disable(); map1.Enable(); }; map1.Enable(); PressAndRelease(keyboard.aKey); Assert.That(map1.enabled, Is.False); Assert.That(map2.enabled, Is.True); PressAndRelease(keyboard.bKey); Assert.That(map1.enabled, Is.True); Assert.That(map2.enabled, Is.False); PressAndRelease(keyboard.aKey); Assert.That(map1.enabled, Is.False); Assert.That(map2.enabled, Is.True); }
void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } _inputs = GetComponent <PlayerInput>(); playerActions = _inputs.actions.FindActionMap("Player", true); uiActions = _inputs.actions.FindActionMap("UI", true); playerMove = playerActions.FindAction("Move"); playerLook = playerActions.FindAction("Look"); playerJump = playerActions.FindAction("Jump"); playerRoll = playerActions.FindAction("Roll"); playerDash = playerActions.FindAction("Dash"); cycleTarget = playerActions.FindAction("CycleTarget"); playerAttack = playerActions.FindAction("Attack"); mousePosition = uiActions.FindAction("MousePosition"); playerActions.Disable(); playerJump.performed += OnJump_Pressed; playerJump.canceled += OnJump_Released; playerRoll.performed += OnRoll_Pressed; playerRoll.canceled += OnRoll_Released; playerDash.performed += OnDash_Pressed; playerDash.canceled += OnDash_Released; playerAttack.performed += OnAttack_Pressed; playerAttack.canceled += OnAttack_Released; cycleTarget.performed += OnCycleTarget_Pressed; }
private void OnDisable() { inputs.Disable(); }
void OnDisable() { actionMap.Disable(); }