using  UnityEngine ; public  class  ObjectManipulation  :  MonoBehaviour { public  float =  0.2f ; public  float =  3.0f ; private  float =  1f ; private  float ; private  Ray  ray; private  RaycastHit  hitInfo; private  bool =  false ; private  Vector3  offset; private  float =  5.0f ; private  void OnMouseDown ( ) { isDragging =  true ; offset =  gameObject. transform. position -  GetMouseWorldPosition ( ) ; } private  void OnMouseUp ( ) { isDragging =  false ; } private  void Update ( ) { if  ( isDragging) { Vector3  newPosition =  GetMouseWorldPosition ( )  +  offset; transform. position =  newPosition; } if  ( Input. GetMouseButton ( 1 ) ) { float =  Input. GetAxis ( "Mouse X" ) ; float =  Input. GetAxis ( "Mouse Y" ) ; transform. Rotate ( mousY *  rotationSpeed,  - mousX *  rotationSpeed,  0 ,  Space. World) ; } ray =  Camera. main. ScreenPointToRay ( Input. mousePosition) ; if  ( Physics. Raycast ( ray,  out  hitInfo) ) { if  ( Input. GetAxis ( "Mouse ScrollWheel" )  !=  0 ) { newScale +=  Input. GetAxis ( "Mouse ScrollWheel" )  *  scaleRate; newScale =  Mathf. Clamp ( newScale,  MinScale,  MaxScale) ; transform. localScale =  new  Vector3 ( newScale,  newScale,  newScale) ; } } } private  Vector3  GetMouseWorldPosition ( ) { Vector3  mousePos =  Input. mousePosition; mousePos. z =  - Camera. main. transform. position. z; return  Camera. main. ScreenToWorldPoint ( mousePos) ; } 
}