@@ -31,18 +31,16 @@ public class HandDraggable : MonoBehaviour,
3131
3232 [ Tooltip ( "Scale by which hand movement in z is multipled to move the dragged object." ) ]
3333 public float DistanceScale = 2f ;
34+
35+ public enum RotationModeEnum
36+ {
37+ Default ,
38+ LockObjectRotation ,
39+ OrientTowardUser ,
40+ KeepUpright
41+ }
3442
35- [ Header ( "Rotation Handling (only select one!)" ) ]
36- [ Tooltip ( "Should the object be kept upright as it is being dragged?" ) ]
37- public bool IsKeepUpright = false ;
38-
39- [ Tooltip ( "Should the object be oriented towards the user as it is being dragged?" ) ]
40- public bool IsOrientTowardsUser = true ;
41-
42- [ Tooltip ( "Should the rotation of the object be locked?" ) ]
43- public bool LockRotation = false ;
44-
45- [ Space ( 10 ) ]
43+ public RotationModeEnum RotationMode = RotationModeEnum . Default ;
4644
4745 public bool IsDraggingEnabled = true ;
4846
@@ -200,16 +198,20 @@ private void UpdateDragging()
200198
201199 draggingPosition = pivotPosition + ( targetDirection * targetDistance ) ;
202200
203- if ( IsOrientTowardsUser )
201+ if ( RotationMode == RotationModeEnum . OrientTowardUser )
204202 {
205203 draggingRotation = Quaternion . LookRotation ( HostTransform . position - pivotPosition ) ;
206204 }
207- else if ( IsKeepUpright )
205+ else if ( RotationMode == RotationModeEnum . KeepUpright )
208206 {
209207 Quaternion upRotation = Quaternion . FromToRotation ( HostTransform . up , Vector3 . up ) ;
210- draggingRotation = upRotation * HostTransform . rotation ; ;
208+ draggingRotation = upRotation * HostTransform . rotation ;
209+ }
210+ else if ( RotationMode == RotationModeEnum . LockObjectRotation )
211+ {
212+ draggingRotation = HostTransform . rotation ;
211213 }
212- else if ( ! IsRotationLocked )
214+ else
213215 {
214216 Vector3 objForward = mainCamera . transform . TransformDirection ( objRefForward ) ; // in world space
215217 Vector3 objUp = mainCamera . transform . TransformDirection ( objRefUp ) ; // in world space
0 commit comments