//======= Used to reset the camera position and rotation when exiting edit mode and returning to view mode ======== void ResetCameraToViewMode() { //----- Use itween to set the position and rotation of the camera to the original values that were before going to edit mode ------ iTween.MoveTo(animationCamera, originalPosition, cameraResetToViewModeSpeed); iTween.RotateTo(animationCamera, originalRotation, cameraResetToViewModeSpeed); //----- Set camera status to View Mode ----- camStatus = cameraStatus.ViewMode; TBDragOrbitScript.IdealPitch = 0f; TBDragOrbitScript.IdealYaw = 0f; TBDragOrbitScript.Yaw = 0f; TBDragOrbitScript.Pitch = 0f; }
//===== Used for direct call or focusing the camera on objects ===== public void FocusCameraOnObject(GameObject selectedObject, CabinetScript.TypeOfCabinet objectType) { //-------------- Saving camera position --------------- //StoreOriginalPosition(animationCamera.transform.position); //-------------- Saving camera rotation --------------- //StoreOriginalRotation(); //---------- Calculate new camera position ---------- Vector3 position = PositionCamera(selectedObject, objectType); //----------- Tween to new position ----------- iTween.MoveTo(animationCamera, position, cameraFocusOnObjectSpeed); //----------- Calculate new camera rotation ------------------- Vector3 rotation = RotateCamera(selectedObject, objectType); //------------- Tween new rotation ------------ iTween.RotateTo(animationCamera, rotation, cameraFocusOnObjectSpeed); //----Change Camera status to Edit Mode----It is used as check before re-enabling tb orbit script---- camStatus = cameraStatus.EditMode; }
//======= Used to reset the camera position and rotation when exiting edit mode and returning to view mode ======== void ResetCameraToViewMode() { //----- Use itween to set the position and rotation of the camera to the original values that were before going to edit mode ------ iTween.MoveTo(animationCamera,originalPosition,cameraResetToViewModeSpeed); iTween.RotateTo(animationCamera,originalRotation,cameraResetToViewModeSpeed); //----- Set camera status to View Mode ----- camStatus = cameraStatus.ViewMode; TBDragOrbitScript.IdealPitch = 0f; TBDragOrbitScript.IdealYaw = 0f; TBDragOrbitScript.Yaw = 0f; TBDragOrbitScript.Pitch = 0f; }
//===== Used for direct call or focusing the camera on objects ===== public void FocusCameraOnObject(GameObject selectedObject,CabinetScript.TypeOfCabinet objectType) { //-------------- Saving camera position --------------- //StoreOriginalPosition(animationCamera.transform.position); //-------------- Saving camera rotation --------------- //StoreOriginalRotation(); //---------- Calculate new camera position ---------- Vector3 position = PositionCamera(selectedObject,objectType); //----------- Tween to new position ----------- iTween.MoveTo(animationCamera,position,cameraFocusOnObjectSpeed); //----------- Calculate new camera rotation ------------------- Vector3 rotation = RotateCamera(selectedObject,objectType); //------------- Tween new rotation ------------ iTween.RotateTo(animationCamera,rotation,cameraFocusOnObjectSpeed); //----Change Camera status to Edit Mode----It is used as check before re-enabling tb orbit script---- camStatus = cameraStatus.EditMode; }