private void OnInputEndEdit(string value) { bool notEmptyCmd = !string.IsNullOrEmpty(value); if (notEmptyCmd) { m_inputField.text = string.Empty; if (m_inputManager.GetButton(InputAction.A, LocalPlayerIndex, false, false) || m_inputManager.GetButton(InputAction.LB, LocalPlayerIndex, false, false) || m_inputManager.GetButton(InputAction.RB, LocalPlayerIndex, false, false) || m_inputManager.GetButton(InputAction.Submit, LocalPlayerIndex, false, false) || LocalPlayerIndex == -1 && m_inputField.gameObject.activeInHierarchy) { Write(value); } } //if (m_isExpanded && notEmptyCmd) //{ // m_coSelect = CoSelect(); // StartCoroutine(m_coSelect); // // IndependentSelectable.Select(m_inputField.gameObject); // //InputFieldWithVirtualKeyboard.ActivateInputField(m_inputField); //} }
public override bool GetMouseButton(int button) { if (button == 0) { if (m_isKeyboardAndMouse) { return(m_input.GetButton(InputAction.LMB, LocalPlayerIndex, false, false)); } return(m_input.GetButton(InputAction.LB, LocalPlayerIndex, false, false)); } return(false); }
private void Update() { if (CursorHelper.lockState == CursorLockMode.None) { return; } PlayerCamCtrlSettings settings = m_settings.PlayerCamCtrl[LocalPlayerIndex]; float cursorX = m_inputManager.GetAxisRaw(InputAction.CursorX, LocalPlayerIndex, false, false); float cursorY = m_inputManager.GetAxisRaw(InputAction.CursorY, LocalPlayerIndex, false, false); if (m_gameState.IsActionsMenuOpened(LocalPlayerIndex) || m_gameState.IsMenuOpened(LocalPlayerIndex) || m_gameState.IsPaused || m_gameState.IsPauseStateChanging || m_camPixelRect.size == Vector2.zero || m_boxSelector.IsActive) { if (m_prevMouseOffset != Vector3.zero) { CursorIconFromMouseOffset(Vector3.zero); m_prevMouseOffset = Vector3.zero; } if (m_isVirtualMouseEnabled) { m_clampCursorPadding = 1; VirtualMousePosition += new Vector2(cursorX, cursorY) * settings.CursorSensitivity; m_clampCursorPadding = 0; } AnimatePivotPoint(settings.MoveSensitivity / 2, settings.MoveSensitivity / 8); return; } Vector3 mouseOffset = GetVirtualMouseOffset(); if (IsInputEnabled && !m_lockInputDuringPivotAnimation) { float deltaY = m_inputManager.GetAxisRaw(InputAction.MoveForward, LocalPlayerIndex, true, false); float deltaX = m_inputManager.GetAxisRaw(InputAction.MoveSide, LocalPlayerIndex, true, false); bool rotateCamCW = m_inputManager.GetButton(InputAction.LT, LocalPlayerIndex, true, false); bool rotateCamCCW = m_inputManager.GetButton(InputAction.RT, LocalPlayerIndex, true, false); bool aPressed = m_inputManager.GetButton(InputAction.A, LocalPlayerIndex); bool pivotPreciseMode = aPressed | m_inputManager.GetButton(InputAction.RightStickButton, LocalPlayerIndex, true, false); bool cursorPreciseMode = aPressed | m_inputManager.GetButton(InputAction.LeftStickButton, LocalPlayerIndex, true, false); if (m_inputManager.IsAnyButtonDown(LocalPlayerIndex, false, false)) { m_lockMouseToWorld = false; } if (m_inputManager.GetButtonUp(InputAction.LT, LocalPlayerIndex, true, false) || m_inputManager.GetButtonUp(InputAction.RT, LocalPlayerIndex, true, false)) { if (!rotateCamCW && !rotateCamCCW) { m_cursorIcon.sprite = m_spritePointer; } } if (m_inputManager.GetButtonUp(InputAction.MMB, LocalPlayerIndex)) { m_cursorIcon.sprite = m_spritePointer; } else if (m_inputManager.GetButton(InputAction.MMB, LocalPlayerIndex)) { m_lockMouseToWorld = false; MoveVirtualMouseToCenterOfScreen(); m_camAngle += Time.deltaTime * cursorX * m_settings.PlayerCamCtrl[LocalPlayerIndex].RotateSensitivity; SetCameraPosition(); if (cursorX != 0) { m_cursorIcon.sprite = cursorX > 0 ? m_spriteRotateCW : m_spriteRotateCCW; } else { m_cursorIcon.sprite = m_spritePointer; } cursorX = 0; cursorY = 0; } else { if (rotateCamCW && !rotateCamCCW) { m_cursorIcon.sprite = m_spriteRotateCW; MoveVirtualMouseToCenterOfScreen(); m_camAngle += Time.deltaTime * settings.RotateSensitivity; SetCameraPosition(); } else if (rotateCamCCW && !rotateCamCW) { m_cursorIcon.sprite = m_spriteRotateCCW; MoveVirtualMouseToCenterOfScreen(); m_camAngle -= Time.deltaTime * settings.RotateSensitivity; SetCameraPosition(); } if (cursorX != 0 && cursorY != 0) { float cursorSens = settings.CursorSensitivity; if (cursorPreciseMode || pivotPreciseMode) { cursorSens /= 5.0f; } else { cursorSens *= VirtualMouseSensitivityScale; } if (m_isVirtualMouseEnabled) { VirtualMousePosition += new Vector2(cursorX, cursorY) * cursorSens; } m_lockMouseToWorld = false; } } Vector3 deltaOffset = new Vector3(deltaX, deltaY, 0); Vector3 offset = Vector2.zero; if (deltaOffset != Vector3.zero) { offset = deltaOffset; mouseOffset = Vector2.zero; } else { if (!m_lockMouseToWorld) { offset = mouseOffset; } } MovePivot(settings, pivotPreciseMode, cursorPreciseMode, offset); if (m_prevMouseOffset != mouseOffset) { CursorIconFromMouseOffset(mouseOffset); m_prevMouseOffset = mouseOffset; } } AnimatePivotPoint(settings.MoveSensitivity / 2, settings.MoveSensitivity / 8); if (m_lockMouseToWorld) { Vector2 targetMousePos = m_camera.WorldToScreenPoint(m_lockMousePosWorld); if (m_animateMousePosition) { SetVirtualMousePosition(Vector2.Lerp(VirtualMousePosition, targetMousePos, Time.deltaTime * 20)); CursorIconFromMouseOffset(mouseOffset); } else { SetVirtualMousePosition(targetMousePos); CursorIconFromMouseOffset(mouseOffset); } } Debug.DrawLine(Pivot, Pivot + Vector3.up, Color.red); }
private void Update() { if (m_gameState.IsActionsMenuOpened(LocalPlayerIndex)) { if (!m_cameraController.IsInputEnabled) { m_cameraController.IsInputEnabled = true; } return; } if (m_gameState.IsMenuOpened(LocalPlayerIndex)) { if (!m_cameraController.IsInputEnabled) { m_cameraController.IsInputEnabled = true; } return; } if (m_gameState.IsContextActionInProgress(LocalPlayerIndex)) { if (!m_cameraController.IsInputEnabled) { m_cameraController.IsInputEnabled = true; } return; } if (m_gameState.IsPaused || m_gameState.IsPauseStateChanging) { return; } if (m_gameState.IsReplay) { return; } int playerIndex = PlayerIndex; m_selectInterval -= Time.deltaTime; m_unselectInterval -= Time.deltaTime; bool multiselect = m_inputManager.GetButton(InputAction.RB, LocalPlayerIndex); if (m_inputManager.GetButtonDown(InputAction.LMB, LocalPlayerIndex)) { RaycastHit hitInfo; if (Physics.Raycast(m_cameraController.Ray, out hitInfo)) { Voxel voxel = hitInfo.transform.GetComponentInParent <Voxel>(); if (voxel != null) { VoxelData data = voxel.VoxelData; if (VoxelData.IsControllableUnit(data.Type) && data.Owner == playerIndex) { m_unitSelection.ClearSelection(playerIndex); m_unitSelection.Select(playerIndex, playerIndex, new[] { data.UnitOrAssetIndex }); } else { m_unitSelection.ClearSelection(playerIndex); } } else { m_unitSelection.ClearSelection(playerIndex); } } else { m_unitSelection.ClearSelection(playerIndex); } if (m_boxSelector != null) { m_boxSelector.Activate(); } } if (m_inputManager.GetButtonDown(InputAction.LB, LocalPlayerIndex)) { bool select = true; if (multiselect) { long[] units = m_gameState.GetUnits(playerIndex).ToArray(); long unitIndex = GetAt(units, m_cameraController.MapCursor); if (m_unitSelection.IsSelected(playerIndex, playerIndex, unitIndex)) { m_unitSelection.Unselect(playerIndex, playerIndex, new[] { unitIndex }); m_wasSelected.Remove(unitIndex); select = false; } } if (select) { Select(playerIndex, multiselect); m_selectInterval = 0.3f; m_unselectInterval = float.PositiveInfinity; m_multiselectMode = true; } else { m_selectInterval = float.PositiveInfinity; m_unselectInterval = 0.3f; } } else if (m_inputManager.GetButton(InputAction.LB, LocalPlayerIndex)) { if (m_selectInterval <= 0) { Select(playerIndex, multiselect); m_selectInterval = 0.2f; } if (m_unselectInterval <= 0) { Unselect(playerIndex); m_unselectInterval = 0.2f; } m_cameraController.IsInputEnabled = false; } else if (m_inputManager.GetButtonUp(InputAction.LB, LocalPlayerIndex, false, false)) { m_cameraController.IsInputEnabled = true; } if (m_inputManager.GetButtonDown(InputAction.RB, LocalPlayerIndex)) { m_multiselectMode = false; } else if (m_inputManager.GetButtonUp(InputAction.RB, LocalPlayerIndex)) { if (!m_multiselectMode) { if (!m_targetSelection.HasSelected(playerIndex)) { m_wasSelected.Clear(); m_unitSelection.ClearSelection(playerIndex); } } } }
private void Update() { if (m_gameState.IsActionsMenuOpened(m_viewport.LocalPlayerIndex)) { return; } if (m_gameState.IsMenuOpened(m_viewport.LocalPlayerIndex)) { return; } if (m_gameState.IsPaused || m_gameState.IsPauseStateChanging) { return; } Transform camTransform = m_viewport.Camera.transform; if (camTransform.position != m_prevCamPos || camTransform.rotation != m_prevCamRot) { m_prevCamPos = camTransform.position; m_prevCamRot = camTransform.rotation; float angle = camTransform.eulerAngles.y; m_rtMapBounds.rotation = Quaternion.Euler(new Vector3(0, 0, angle)); ProjectCamera(m_rtMapBounds.rotation); } if (m_input.GetButtonDown(InputAction.Start, m_viewport.LocalPlayerIndex, false, false)) { m_gotFocus = !m_gotFocus; if (m_gotFocus) { m_eventSystem.SetSelectedGameObjectOnLateUpdate(m_selectableMinimap.gameObject); } else { m_cameraController.CenterVirtualMouse(); m_eventSystem.SetSelectedGameObjectOnLateUpdate(null); } } if (m_input.GetButtonDown(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false)) { Vector2 pt; if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)m_rtMapBounds.parent, m_cameraController.VirtualMousePosition, null, out pt)) { float normalizedDistance = pt.magnitude / m_rootRadius; if (normalizedDistance <= 1) { m_mouseManipulation = true; m_virtualMousePostion = m_cameraController.VirtualMousePosition; Move(camTransform, true, 0, 0, 0, 0); } } } else if (m_input.GetButtonUp(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false)) { m_mouseManipulation = false; } if (m_gotFocus || m_input.GetButton(InputAction.LB, m_viewport.LocalPlayerIndex, false, false) && IsCursorInMinimapBounds()) { if (m_input.GetButtonDown(InputAction.B, m_viewport.LocalPlayerIndex, false, false)) { m_gotFocus = false; m_cameraController.CenterVirtualMouse(); m_eventSystem.SetSelectedGameObjectOnLateUpdate(null); } else if (m_input.GetButtonDown(InputAction.LB, m_viewport.LocalPlayerIndex, false, false)) { m_virtualMousePostion = m_cameraController.VirtualMousePosition; Move(camTransform, true, 0, 0, 0, 0); } else { bool aPressed = m_input.GetButton(InputAction.A, m_viewport.LocalPlayerIndex, false, false); bool pivotPreciseMode = aPressed | m_input.GetButton(InputAction.RightStickButton, m_viewport.LocalPlayerIndex, false, false); float pivotMultiplier = 1; if (!pivotPreciseMode) { pivotMultiplier = 5; } float deltaY = m_input.GetAxisRaw(InputAction.MoveForward, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.MoveSensitivity * pivotMultiplier; float deltaX = m_input.GetAxisRaw(InputAction.MoveSide, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.MoveSensitivity * pivotMultiplier; bool cursorPreciseMode = aPressed | m_input.GetButton(InputAction.LeftStickButton, m_viewport.LocalPlayerIndex, false, false); float cursorMultiplier = 4; if (!cursorPreciseMode) { cursorMultiplier = 12; } float cursorY = m_input.GetAxisRaw(InputAction.CursorY, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; float cursorX = m_input.GetAxisRaw(InputAction.CursorX, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; Move(camTransform, false, deltaY, deltaX, cursorY, cursorX); } } if (m_mouseManipulation) { if (m_input.GetButton(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false)) { float cursorMultiplier = 12; float cursorY = m_input.GetAxisRaw(InputAction.CursorY, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; float cursorX = m_input.GetAxisRaw(InputAction.CursorX, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; Move(camTransform, false, cursorY, cursorX, 0, 0); } } }
private void Update() { if (m_inputManager.GetButtonDown(InputAction.EditorCreate, m_mapEditorOwner)) { m_lastModifiedCell = null; m_editorCreateButtonDown = true; } if (m_inputManager.GetButtonUp(InputAction.EditorCreate, m_mapEditorOwner)) { m_lastModifiedCell = null; m_editorCreateButtonDown = false; } if (m_inputManager.GetButtonDown(InputAction.EditorDestroy, m_mapEditorOwner)) { m_lastModifiedCell = null; m_editorDestroyButtonDown = true; } if (m_inputManager.GetButtonUp(InputAction.EditorDestroy, m_mapEditorOwner)) { m_lastModifiedCell = null; m_editorDestroyButtonDown = false; } if (m_inputManager.GetButton(InputAction.EditorCreate, m_mapEditorOwner)) { if (m_editorCreateButtonDown) { CreateVoxel(); } } else if (m_inputManager.GetButton(InputAction.EditorDestroy, m_mapEditorOwner)) { if (m_editorDestroyButtonDown) { DestroyVoxel(); } } if (m_inputManager.GetButtonDown(InputAction.EditorPan, m_mapEditorOwner)) { m_lastMousePosition = m_inputManager.MousePosition; m_prevPivotPosition = m_pivot.transform.position; } else if (m_inputManager.GetButtonUp(InputAction.EditorPan, m_mapEditorOwner)) { m_editorCamera.enabled = false; } bool pan = m_inputManager.GetButton(InputAction.EditorPan, m_mapEditorOwner); bool rotate = m_inputManager.GetButton(InputAction.EditorRotate, m_mapEditorOwner); if (!pan && !rotate) { m_editorCamera.Zoom(); } if (rotate) { if (pan) { m_editorCamera.enabled = true; } } else { m_editorCamera.enabled = false; if (pan) { Pan(); } } }