public Vector3 GetModifiedPosition(IMixedRealityCursor cursor) { if (SnapCursorPosition) { // Snap if the targeted object has a cursor modifier that supports snapping return(HostTransform.position + HostTransform.TransformVector(CursorPositionOffset)); } if (cursor.Pointer == null) { Debug.LogError($"{cursor.GameObjectReference.name} has no pointer set in it's cursor component!"); return(Vector3.zero); } FocusDetails focusDetails; if (InputSystem?.FocusProvider != null && InputSystem.FocusProvider.TryGetFocusDetails(cursor.Pointer, out focusDetails)) { // Else, consider the modifiers on the cursor modifier, but don't snap return(focusDetails.Point + HostTransform.TransformVector(CursorPositionOffset)); } return(Vector3.zero); }
protected override void ApplyTransformation(Vector3 pivotPosition, Vector3 newDraggingPosition, Vector3 delta) { // sum the components of the delta vector to get a unified rotation magnitude and convert to degrees float rotationFactor = Mathf.Rad2Deg * (delta.x + delta.y + delta.z); HostTransform.Rotate(new Vector3(0, rotationFactor, 0)); draggingPosition = newDraggingPosition; }
private void OnValidate() { Debug.Assert(HostTransform.GetComponent <Collider>() != null, $"A collider component is required on {hostTransform.gameObject.name} for the cursor modifier component on {gameObject.name} to function properly."); }