protected virtual bool PanAction() { IInput input = m_component.Editor.Input; RuntimeTools tools = m_component.Editor.Tools; return(input.GetPointer(2) || input.GetPointer(SwapLRMB ? 1 : 0) && tools.Current == RuntimeTool.View && tools.ActiveTool == null); }
protected virtual bool PanAction() { IInput input = m_component.Editor.Input; RuntimeTools tools = m_component.Editor.Tools; return(input.GetPointer(2) || input.GetPointer(1) || input.GetPointer(0) && tools.Current == RuntimeTool.View); }
protected virtual bool FreeMoveAction() { IInput input = m_component.Editor.Input; RuntimeTools tools = m_component.Editor.Tools; if (SwapLRMB) { return(input.GetPointer(0) && RotateAction()); } return(input.GetPointer(1)); }
protected override void UpdateOverride() { base.UpdateOverride(); if (HightlightOnHover && !IsDragging) { if (RuntimeTools.IsPointerOverGameObject()) { return; } SelectedAxis = Hit(); } }
protected virtual void SelectGO() { RuntimeTools tools = m_component.Editor.Tools; IRuntimeSelection selection = m_component.Selection; if (tools.ActiveTool != null && tools.ActiveTool != m_component.BoxSelection) { return; } if (tools.IsViewing) { return; } if (!selection.Enabled) { return; } OnSelectGO(); }
protected override void UpdateOverride() { base.UpdateOverride(); if (RuntimeTools.IsPointerOverGameObject()) { return; } if (!IsDragging) { if (HightlightOnHover) { m_targetInverseMatrix = Matrix4x4.TRS(Target.position, Target.rotation * StartingRotationInv, Vector3.one).inverse; SelectedAxis = Hit(); } if (m_targetRotation != Target.rotation) { m_startingRotation = Target.rotation; m_startinRotationInv = Quaternion.Inverse(m_startingRotation); m_targetRotation = Target.rotation; } } }
protected override void UpdateOverride() { base.UpdateOverride(); if (RuntimeTools.IsPointerOverGameObject()) { return; } if (IsDragging) { if ((SnapToGround || InputController.GetKey(SnapToGroundKey)) && SelectedAxis != RuntimeHandleAxis.Y) { SnapActiveTargetsToGround(ActiveTargets, SceneCamera, true); transform.position = Targets[0].position; } } if (HightlightOnHover && !IsDragging) { SelectedAxis = Hit(); } if (InputController.GetKeyDown(SnappingKey)) { if (!LockObject.IsPositionLocked) { m_isInSnappingMode = true; if (InputController.GetKey(SnappingToggle)) { RuntimeTools.IsSnapping = !RuntimeTools.IsSnapping; } BeginSnap(); m_prevMousePosition = Input.mousePosition; } } else if (InputController.GetKeyUp(SnappingKey)) { SelectedAxis = RuntimeHandleAxis.None; m_isInSnappingMode = false; if (!IsInSnappingMode) { m_handleOffset = Vector3.zero; } } if (IsInSnappingMode) { Vector2 mousePosition = Input.mousePosition; if (RuntimeTools.SnappingMode == SnappingMode.BoundingBox) { if (IsDragging) { SelectedAxis = RuntimeHandleAxis.Snap; if (m_prevMousePosition != mousePosition) { m_prevMousePosition = mousePosition; float minDistance = float.MaxValue; Vector3 minPoint = Vector3.zero; bool minPointFound = false; for (int i = 0; i < m_allExposedToEditor.Length; ++i) { ExposeToEditor exposeToEditor = m_allExposedToEditor[i]; Bounds bounds = exposeToEditor.Bounds; m_boundingBoxCorners[0] = bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[1] = bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[2] = bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[3] = bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[4] = bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[5] = bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[6] = bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[7] = bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, -bounds.extents.z); GetMinPoint(ref minDistance, ref minPoint, ref minPointFound, exposeToEditor.BoundsObject.transform); } if (minPointFound) { HandlePosition = minPoint; } } } else { SelectedAxis = RuntimeHandleAxis.None; if (m_prevMousePosition != mousePosition) { m_prevMousePosition = mousePosition; float minDistance = float.MaxValue; Vector3 minPoint = Vector3.zero; bool minPointFound = false; for (int i = 0; i < m_snapTargets.Length; ++i) { Transform snapTarget = m_snapTargets[i]; Bounds bounds = m_snapTargetsBounds[i]; m_boundingBoxCorners[0] = bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[1] = bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[2] = bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[3] = bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[4] = bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[5] = bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[6] = bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[7] = bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, -bounds.extents.z); if (Targets[i] != null) { GetMinPoint(ref minDistance, ref minPoint, ref minPointFound, snapTarget); } } if (minPointFound) { m_handleOffset = minPoint - transform.position; } } } } else { if (IsDragging) { SelectedAxis = RuntimeHandleAxis.Snap; if (m_prevMousePosition != mousePosition) { m_prevMousePosition = mousePosition; Ray ray = SceneCamera.ScreenPointToRay(mousePosition); RaycastHit hitInfo; LayerMask layerMask = (1 << Physics.IgnoreRaycastLayer); layerMask = ~layerMask; for (int i = 0; i < m_snapTargets.Length; ++i) { m_targetLayers[i] = m_snapTargets[i].gameObject.layer; m_snapTargets[i].gameObject.layer = Physics.IgnoreRaycastLayer; } GameObject closestObject = null; if (Physics.Raycast(ray, out hitInfo, float.PositiveInfinity, layerMask)) { closestObject = hitInfo.collider.gameObject; } else { float minDistance = float.MaxValue; for (int i = 0; i < m_allExposedToEditor.Length; ++i) { ExposeToEditor exposedToEditor = m_allExposedToEditor[i]; Bounds bounds = exposedToEditor.Bounds; m_boundingBoxCorners[0] = bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[1] = bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[2] = bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[3] = bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[4] = bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[5] = bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, -bounds.extents.z); m_boundingBoxCorners[6] = bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, bounds.extents.z); m_boundingBoxCorners[7] = bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, -bounds.extents.z); for (int j = 0; j < m_boundingBoxCorners.Length; ++j) { Vector2 screenPoint = SceneCamera.WorldToScreenPoint(exposedToEditor.BoundsObject.transform.TransformPoint(m_boundingBoxCorners[j])); float distance = (screenPoint - mousePosition).magnitude; if (distance < minDistance) { closestObject = exposedToEditor.gameObject; minDistance = distance; } } } } if (closestObject != null) { float minDistance = float.MaxValue; Vector3 minPoint = Vector3.zero; bool minPointFound = false; Transform meshTransform; Mesh mesh = GetMesh(closestObject, out meshTransform); GetMinPoint(meshTransform, ref minDistance, ref minPoint, ref minPointFound, mesh); if (minPointFound) { HandlePosition = minPoint; } } for (int i = 0; i < m_snapTargets.Length; ++i) { m_snapTargets[i].gameObject.layer = m_targetLayers[i]; } } } else { SelectedAxis = RuntimeHandleAxis.None; if (m_prevMousePosition != mousePosition) { m_prevMousePosition = mousePosition; float minDistance = float.MaxValue; Vector3 minPoint = Vector3.zero; bool minPointFound = false; for (int i = 0; i < RealTargets.Length; ++i) { Transform snapTarget = RealTargets[i]; Transform meshTranform; Mesh mesh = GetMesh(snapTarget.gameObject, out meshTranform); GetMinPoint(meshTranform, ref minDistance, ref minPoint, ref minPointFound, mesh); } if (minPointFound) { m_handleOffset = minPoint - transform.position; } } } } } }
private void LateUpdate() { if (RuntimeTools.ActiveTool != null && RuntimeTools.ActiveTool != this) { return; } if (RuntimeTools.IsViewing) { return; } if (KeyCode == KeyCode.None || InputController.GetKeyDown(KeyCode)) { m_active = true; } if (m_active) { if (Input.GetMouseButtonDown(MouseButton)) { m_startMousePosition = Input.mousePosition; m_isDragging = GetPoint(out m_startPt) && (!RuntimeEditorApplication.IsOpened || RuntimeEditorApplication.IsPointerOverWindow(RuntimeWindowType.SceneView) && !RuntimeTools.IsPointerOverGameObject()); if (m_isDragging) { m_rectTransform.anchoredPosition = m_startPt; m_rectTransform.sizeDelta = new Vector2(0, 0); CursorHelper.SetCursor(this, null, Vector3.zero, CursorMode.Auto); } else { RuntimeTools.ActiveTool = null; } } else if (Input.GetMouseButtonUp(MouseButton)) { if (m_isDragging) { m_isDragging = false; HitTest(); m_rectTransform.sizeDelta = new Vector2(0, 0); CursorHelper.ResetCursor(this); } RuntimeTools.ActiveTool = null; m_active = false; } else if (m_isDragging) { GetPoint(out m_endPt); Vector2 size = m_endPt - m_startPt; if (size != Vector2.zero) { RuntimeTools.ActiveTool = this; } m_rectTransform.sizeDelta = new Vector2(Mathf.Abs(size.x), Mathf.Abs(size.y)); m_rectTransform.localScale = new Vector3(Mathf.Sign(size.x), Mathf.Sign(size.y), 1); } } }
private void HandleInput() { if (RuntimeTools.AutoFocus) { do { if (RuntimeTools.ActiveTool != null) { break; } if (m_autoFocusTransform == null) { break; } if (m_autoFocusTransform.position == SecondaryPivot.position) { break; } if (m_focusAnimation != null && m_focusAnimation.InProgress) { break; } Vector3 offset = (m_autoFocusTransform.position - SecondaryPivot.position); SceneCamera.transform.position += offset; Pivot.transform.position += offset; SecondaryPivot.transform.position += offset; }while (false); } if (InputController._GetMouseButtonUp(0) || InputController._GetMouseButtonUp(1) || InputController._GetMouseButtonUp(2)) { m_handleInput = false; m_mouseOrbit.enabled = false; m_rotate = false; SetCursor(); return; } bool isGameViewActive = RuntimeEditorApplication.IsActiveWindow(RuntimeWindowType.GameView); if (!isGameViewActive) { float mouseWheel = InputController._GetAxis("Mouse ScrollWheel"); if (mouseWheel != 0) { if (!RuntimeTools.IsPointerOverGameObject()) { m_mouseOrbit.Zoom(); } } } if (m_lockInput) { return; } if (!isGameViewActive) { if (InputController._GetKeyDown(SnapToGridKey) && InputController._GetKey(ModifierKey)) { SnapToGrid(); } if (InputController._GetKeyDown(FocusKey)) { Focus(); } bool rotate = InputController._GetKey(RotateKey) || InputController._GetKey(RotateKey2) || InputController._GetKey(RotateKey3); bool pan = InputController._GetMouseButton(2) || InputController._GetMouseButton(1) || InputController._GetMouseButton(0) && RuntimeTools.Current == RuntimeTool.View; if (pan != m_pan) { m_pan = pan; if (m_pan) { if (RuntimeTools.Current != RuntimeTool.View) { m_rotate = false; } m_dragPlane = new Plane(-SceneCamera.transform.forward, Pivot.position); } SetCursor(); } else { if (rotate != m_rotate) { m_rotate = rotate; SetCursor(); } } } RuntimeTools.IsViewing = m_rotate || m_pan; bool isLocked = RuntimeTools.IsViewing || isGameViewActive; if (!IPointerOverEditorArea) { return; } bool isMouse0ButtonDown = InputController._GetMouseButtonDown(0); bool isMouse1ButtonDown = InputController._GetMouseButtonDown(1); bool isMouse2ButtonDown = InputController._GetMouseButtonDown(2); if (isMouse0ButtonDown || isMouse1ButtonDown || isMouse2ButtonDown) { m_handleInput = !PositionHandle.IsDragging; m_lastMousePosition = InputController._MousePosition; if (m_rotate) { m_mouseOrbit.enabled = true; } } if (m_handleInput) { if (isLocked) { if (m_pan && (!m_rotate || RuntimeTools.Current != RuntimeTool.View)) { Pan(); } } } }
protected override void LateUpdate() { if (!m_component.IsWindowActive) { return; } bool isPointerOverAndSelected = m_component.Window.IsPointerOver;// && m_component.IsUISelected; IInput input = m_component.Editor.Input; RuntimeTools tools = m_component.Editor.Tools; bool canRotate = AllowRotateAction(); bool rotate = RotateAction(); bool pan = PanAction(); bool freeMove = FreeMoveAction(); if (pan && tools.Current != RuntimeTool.View) { rotate = false; } bool beginRotate = m_rotate != rotate && rotate; if (beginRotate && !isPointerOverAndSelected) { rotate = false; beginRotate = false; } bool endRotate = m_rotate != rotate && !rotate; m_rotate = rotate; bool beginPan = m_pan != pan && pan; if (beginPan && !isPointerOverAndSelected) { pan = false; } bool endPan = m_pan != pan && !pan; m_pan = pan; bool beginFreeMove = m_freeMove != freeMove && freeMove; if (beginFreeMove && !isPointerOverAndSelected) { freeMove = false; } bool endFreeMove = m_freeMove != freeMove && !freeMove; m_freeMove = freeMove; Vector3 pointerPosition = input.GetPointerXY(0); tools.IsViewing = m_rotate || m_pan || m_freeMove; if (beginPan || endPan || beginRotate || endRotate || beginFreeMove || endFreeMove) { SceneComponent.UpdateCursorState(true, m_pan, m_rotate, m_freeMove); } if (m_freeMove) { SceneComponent.FreeMove(RotateAxes() * FreeRotateSensitivity, MoveAxes() * FreeMoveSensitivity, ZoomAxis()); } else if (m_rotate) { if (canRotate) { Vector2 orbitAxes = RotateAxes(); SceneComponent.Orbit(orbitAxes.x * RotateXSensitivity, orbitAxes.y * RotateYSensitivity, ZoomAxis() * MoveZSensitivity); } else { Transform camTransform = m_component.Window.Camera.transform; Ray pointer = m_component.Window.Pointer; SceneComponent.Zoom(ZoomAxis() * MoveZSensitivity, Quaternion.FromToRotation(Vector3.forward, (camTransform.InverseTransformVector(pointer.direction)).normalized)); } SceneComponent.FreeMove(Vector2.zero, Vector3.zero, 0); } else if (m_pan) { if (beginPan) { SceneComponent.BeginPan(pointerPosition); } SceneComponent.Pan(pointerPosition); } else { SceneComponent.FreeMove(Vector2.zero, Vector3.zero, 0); if (isPointerOverAndSelected) { SceneComponent.Zoom(ZoomAxis() * MoveZSensitivity, Quaternion.identity); if (SelectAction()) { SelectGO(); } if (SnapToGridAction()) { SceneComponent.SnapToGrid(); } if (FocusAction()) { SceneComponent.Focus(); } if (SelectAllAction()) { SceneComponent.SelectAll(); } } } }
private void Update() { if (InputController._GetMouseButtonDown(0)) { if (RuntimeTools.Current != Tool && RuntimeTools.Current != RuntimeTool.None || RuntimeTools.IsViewing) { return; } if (RuntimeTools.IsPointerOverGameObject()) { return; } if (SceneCamera == null) { Debug.LogError("Camera is null"); return; } if (RuntimeTools.ActiveTool != null) { return; } if (RuntimeEditorApplication.ActiveSceneCamera != null && !RuntimeEditorApplication.IsPointerOverWindow(RuntimeWindowType.SceneView)) { return; } m_isDragging = OnBeginDrag(); if (m_isDragging) { RuntimeTools.ActiveTool = this; RecordTransform(); } else { RuntimeTools.ActiveTool = null; } } else if (InputController._GetMouseButtonUp(0)) { TryCancelDrag(); } else { if (m_isDragging) { if (InputController._GetKey(UnitSnapKey) || RuntimeTools.UnitSnapping) { EffectiveGridUnitSize = CurrentGridUnitSize; } else { EffectiveGridUnitSize = 0; } OnDrag(); } } UpdateOverride(); if (Model != null) { SyncModelTransform(); } if (m_isDragging) { if (RuntimeTools.PivotMode == RuntimePivotMode.Center && m_commonCenterTarget != null && m_realTargets != null && m_realTargets.Length > 1) { for (int i = 0; i < m_commonCenterTarget.Length; ++i) { Transform commonCenterTarget = m_commonCenterTarget[i]; Transform target = m_realTargets[i]; target.transform.position = commonCenterTarget.position; target.transform.rotation = commonCenterTarget.rotation; target.transform.localScale = commonCenterTarget.localScale; } } } }
protected override void LateUpdate() { if (!m_component.IsWindowActive) { return; } bool isPointerOverAndSelected = m_component.Window.IsPointerOver && m_component.IsUISelected; IInput input = m_component.Editor.Input; RuntimeTools tools = m_component.Editor.Tools; bool canRotate = AllowRotateAction(); bool rotate = RotateAction(); bool pan = PanAction(); if (pan) { rotate = false; } bool beginRotate = m_rotate != rotate && rotate; if (beginRotate && !isPointerOverAndSelected) { rotate = false; beginRotate = false; } bool endRotate = m_rotate != rotate && !rotate; m_rotate = rotate; bool beginPan = m_pan != pan && pan; if (beginPan && !isPointerOverAndSelected) { pan = false; } bool endPan = m_pan != pan && !pan; m_pan = pan; Vector3 pointerPosition = input.GetPointerXY(0); tools.IsViewing = m_rotate || m_pan; if (beginPan || endPan || beginRotate || endRotate) { SceneComponent.UpdateCursorState(true, m_pan, m_rotate); } if (beginPan) { SceneComponent.BeginPan(pointerPosition); } if (m_rotate) { if (canRotate) { Vector2 orbitAxes = OrbitAxes(); SceneComponent.Orbit(orbitAxes.x, orbitAxes.y, 0); } } else if (m_pan) { SceneComponent.Pan(pointerPosition); } else { if (isPointerOverAndSelected) { SceneComponent.Orbit(0, 0, ZoomAxis()); if (SelectAction()) { SelectGO(); } if (SnapToGridAction()) { SceneComponent.SnapToGrid(); } if (FocusAction()) { SceneComponent.Focus(); } } } }
private void Update() { Sync(); float delta = Time.deltaTime / m_animationDuration; bool updateAlpha = UpdateAlpha(ref m_xAlpha, Vector3.right, delta); updateAlpha |= UpdateAlpha(ref m_yAlpha, Vector3.up, delta); updateAlpha |= UpdateAlpha(ref m_zAlpha, Vector3.forward, delta); if (RuntimeTools.IsPointerOverGameObject()) { if (RuntimeTools.ActiveTool == this) { RuntimeTools.ActiveTool = null; } m_selectedAxis = Vector3.zero; return; } if (RuntimeTools.IsViewing) { m_selectedAxis = Vector3.zero; return; } if (RuntimeTools.ActiveTool != null && RuntimeTools.ActiveTool != this) { m_selectedAxis = Vector3.zero; return; } Vector2 guiMousePositon = Input.mousePosition; guiMousePositon.y = Screen.height - guiMousePositon.y; bool isMouseOverButton = m_buttonRect.Contains(guiMousePositon, true); if (isMouseOverButton) { RuntimeTools.ActiveTool = this; } else { RuntimeTools.ActiveTool = null; } if (m_camera.pixelRect.Contains(Input.mousePosition)) { if (!m_mouseOver || updateAlpha) { EnableColliders(); } Collider collider = HitTest(); if (collider == null || m_rotateAnimation != null && m_rotateAnimation.InProgress) { m_selectedAxis = Vector3.zero; } else if (collider == m_colliderProj) { m_selectedAxis = Vector3.one; } else if (collider == m_colliderUp) { m_selectedAxis = Vector3.up; } else if (collider == m_colliderDown) { m_selectedAxis = Vector3.down; } else if (collider == m_colliderForward) { m_selectedAxis = Vector3.forward; } else if (collider == m_colliderBackward) { m_selectedAxis = Vector3.back; } else if (collider == m_colliderRight) { m_selectedAxis = Vector3.right; } else if (collider == m_colliderLeft) { m_selectedAxis = Vector3.left; } if (m_selectedAxis != Vector3.zero || isMouseOverButton) { //RuntimeTools.IsSceneGizmoSelected = true; RuntimeTools.ActiveTool = this; } else { //RuntimeTools.IsSceneGizmoSelected = false; RuntimeTools.ActiveTool = null; } if (Input.GetMouseButtonUp(0)) { if (m_selectedAxis != Vector3.zero) { if (m_selectedAxis == Vector3.one) { IsOrthographic = !IsOrthographic; } else { if (m_rotateAnimation == null || !m_rotateAnimation.InProgress) { if (OrientationChanging != null) { OrientationChanging.Invoke(); } } if (m_rotateAnimation != null) { m_rotateAnimation.Abort(); } Vector3 pivot = Pivot.transform.position; Vector3 radiusVector = Vector3.back * (SceneCamera.transform.position - pivot).magnitude; Quaternion targetRotation = Quaternion.LookRotation(-m_selectedAxis, Vector3.up); m_rotateAnimation = new QuaternionAnimationInfo(SceneCamera.transform.rotation, targetRotation, 0.4f, QuaternionAnimationInfo.EaseOutCubic, (target, value, t, completed) => { SceneCamera.transform.position = pivot + value * radiusVector; SceneCamera.transform.rotation = value; if (completed) { DisableColliders(); EnableColliders(); if (OrientationChanged != null) { OrientationChanged.Invoke(); } } }); Run.Instance.Animation(m_rotateAnimation); } } } m_mouseOver = true; } else { if (m_mouseOver) { DisableColliders(); RuntimeTools.ActiveTool = null; } m_mouseOver = false; } }
protected override void LateUpdate() { if (!m_component.IsWindowActive) { return; } bool isPointerOverAndSelected = m_component.Window.IsPointerOver; IInput input = m_component.Editor.Input; RuntimeTools tools = m_component.Editor.Tools; bool canRotate = AllowRotateAction(); bool rotate = (RotateAction() || SwapLRMB && canRotate) && SceneComponent.CanRotate; bool pan = PanAction() && SceneComponent.CanPan; bool freeMove = FreeMoveAction() && SceneComponent.CanFreeMove; if (pan && tools.Current != RuntimeTool.View) { rotate = false; } bool beginRotate = m_rotate != rotate && rotate; if (beginRotate && !isPointerOverAndSelected) { rotate = false; beginRotate = false; } bool endRotate = m_rotate != rotate && !rotate; m_rotate = rotate; if (!m_rotate) { m_rotateActive = false; } bool beginPan = m_pan != pan && pan; if (beginPan && !isPointerOverAndSelected) { pan = false; } bool endPan = m_pan != pan && !pan; m_pan = pan; bool beginFreeMove = m_freeMove != freeMove && freeMove; if (beginFreeMove && !isPointerOverAndSelected) { freeMove = false; } bool endFreeMove = m_freeMove != freeMove && !freeMove; m_freeMove = freeMove; if (!m_freeMove) { m_freeMoveActive = false; } Vector3 pointerPosition = input.GetPointerXY(0); tools.IsViewing = m_rotate || m_pan || m_freeMove; if (beginPan || endPan || beginRotate && m_beginRotateImmediately || endRotate || beginFreeMove && m_beginFreeMoveImmediately || endFreeMove) { SceneComponent.UpdateCursorState(true, m_pan, m_rotate && m_beginRotateImmediately, beginFreeMove && m_beginFreeMoveImmediately); } if (m_freeMove) { Vector2 rotateAxes = RotateAxes() * FreeRotateSensitivity; Vector3 moveAxes = MoveAxes() * FreeMoveSensitivity; float zoomAxis = ZoomAxis(); SceneComponent.FreeMove(rotateAxes, moveAxes, zoomAxis); if (!m_freeMoveActive && (rotateAxes != Vector2.zero || moveAxes != Vector3.zero || zoomAxis != 0)) { SceneComponent.UpdateCursorState(true, m_pan, m_rotate, m_freeMove); m_freeMoveActive = true; } } else if (m_rotate) { if (canRotate) { Vector2 orbitAxes = RotateAxes(); float zoomAxis = ZoomAxis(); SceneComponent.Orbit(orbitAxes.x * RotateXSensitivity, orbitAxes.y * RotateYSensitivity, zoomAxis * MoveZSensitivity); if (!m_rotateActive && (orbitAxes != Vector2.zero || zoomAxis != 0)) { SceneComponent.UpdateCursorState(true, m_pan, m_rotate, m_freeMove); m_rotateActive = true; } } else { Transform camTransform = m_component.Window.Camera.transform; Ray pointer = m_component.Window.Pointer; SceneComponent.Zoom(ZoomAxis() * MoveZSensitivity, Quaternion.FromToRotation(Vector3.forward, (camTransform.InverseTransformVector(pointer.direction)).normalized)); } SceneComponent.FreeMove(Vector2.zero, Vector3.zero, 0); } else if (m_pan) { if (beginPan) { SceneComponent.BeginPan(pointerPosition); } SceneComponent.Pan(pointerPosition); } else { SceneComponent.FreeMove(Vector2.zero, Vector3.zero, 0); if (isPointerOverAndSelected) { SceneComponent.Zoom(ZoomAxis() * MoveZSensitivity, Quaternion.identity); BeginSelectAction(); if (SelectAction()) { SelectGO(); } if (SnapToGridAction()) { SceneComponent.SnapToGrid(); } if (FocusAction()) { if (FocusActiveAction()) { SceneComponent.Focus(FocusMode.AllActive); } else { if (SceneComponent.Selection.activeTransform != null && SceneComponent.Selection.activeTransform.GetComponent <Terrain>() == null) { SceneComponent.Focus(FocusMode.Selected); } } } if (SelectAllAction()) { SceneComponent.SelectAll(); } } } }