void Start() { panoControls = GetComponent <PanoControls>(); if (panoControls == null) { Debug.LogError("Couldn't find PanoControls, Please place the GuiControls script on the same object the PanoControls script is attached to"); } if (guiSkinToUse == null) { Debug.LogWarning("A guiskin hasnt been assigned to the GuiControls script, defaulting to Unity's default skin"); } // Prevents the user from clicking through the gui element panoControls.useUnityGuiBasedControls = true; // Adds all the Gui Element Rects to a list, for checking if a touch or click is over a GUI element panoControls.guiButtonRects.Add(panLeftRect); panoControls.guiButtonRects.Add(panRightRect); panoControls.guiButtonRects.Add(panUpRect); panoControls.guiButtonRects.Add(panDownRect); panoControls.guiButtonRects.Add(zoomInRect); panoControls.guiButtonRects.Add(zoomOutRect); }
// Executed when the button "Create panoramic rig" is clicked. Creates the panoramic rig, with the option to undo. void OnWizardCreate() { Undo.RegisterSceneUndo("Create panoramic rig"); Vector3 camPosition = cameraToUse.transform.position; GameObject camPivot = new GameObject("Panoramic Cam Pivot"); camPivot.transform.position = camPosition; cameraToUse.transform.parent = camPivot.transform; if (LayerMask.NameToLayer(layerToAssignTo) != -1 && layerToAssignTo != "") { Transform[] transforms = camPivot.GetComponentsInChildren <Transform>(); foreach (Transform tf in transforms) { tf.gameObject.layer = LayerMask.NameToLayer(layerToAssignTo); } } // Applies all the settings specified in the window to the actual script on the rig if (applyControls) { PanoControls panoControl = camPivot.gameObject.AddComponent <PanoControls>(); if (useGuiControls) { camPivot.gameObject.AddComponent <GuiControls>(); } panoControl.panoCamera = cameraToUse; panoControl.panoCameraPivot = camPivot; panoControl.minZoomFov = minZoom; panoControl.maxZoomFov = maxZoom; cameraToUse.fov = startingZoom; panoControl.useKeyboardControls = useKeyboardControls; panoControl.useMouseControls = useMouseControls; panoControl.useTouchControls = useTouchControls; panoControl.keyboardZoomSpeed = keyboardZoomSpeed; panoControl.mouseZoomSpeed = mouseZoomSpeed; panoControl.touchZoomSpeed = touchZoomSpeed; panoControl.invertMouseZoom = invertMouseZoom; panoControl.keyboardPanSpeed = keyboardPanSpeed; panoControl.mousePanSpeed = mousePanSpeed; panoControl.touchPanSpeed = touchPanSpeed; panoControl.invertMouseVertical = invertMouseVertical; panoControl.invertMouseHorizontal = invertMouseHorizontal; panoControl.invertKeyboardVertical = invertKeyboardVertical; panoControl.invertKeyboardHorizontal = invertKeyboardHorizontal; panoControl.invertTouchVertical = invertTouchVertical; panoControl.invertTouchHorizontal = invertTouchHorizontal; panoControl.hideHotspotsAtStart = hideHotspotsAtStart; if (limitXAxis == true) { panoControl.limitXRotation = true; panoControl.maxLeftRotation = xAxisLeftLimit; panoControl.maxRightRotation = xAxisRightLimit; } else if (limitYAxis == true) { panoControl.limitYRotation = true; panoControl.maxUpRotation = yAxisUpLimit; panoControl.maxDownRotation = yAxisDownLimit; } } }
public override void OnInspectorGUI() { PanoControls panoScript = (PanoControls)target; heading = new GUIStyle(EditorStyles.foldout); heading.fontSize = 12; heading.normal.textColor = Color.white; heading.stretchWidth = true; heading.fontStyle = FontStyle.Bold; GUILayout.Space(20); showCameraRigOptions = EditorGUILayout.Foldout(showCameraRigOptions, "Camera rig objects", heading); if (showCameraRigOptions) { GUILayout.Space(10); panoScript.panoCameraPivot = (GameObject)EditorGUILayout.ObjectField("Pano camera pivot", panoScript.panoCameraPivot, typeof(GameObject), true); panoScript.panoCamera = (Camera)EditorGUILayout.ObjectField("Pano camera", panoScript.panoCamera, typeof(Camera), true); } GUILayout.Space(10); showControlOptions = EditorGUILayout.Foldout(showControlOptions, "Control options", heading); if (showControlOptions) { GUILayout.Space(10); panoScript.useKeyboardControls = EditorGUILayout.Toggle("Use keyboard controls", panoScript.useKeyboardControls); panoScript.useMouseControls = EditorGUILayout.Toggle("Use mouse controls", panoScript.useMouseControls); panoScript.useTouchControls = EditorGUILayout.Toggle("Use touch controls", panoScript.useTouchControls); } GUILayout.Space(10); showZoomOptions = EditorGUILayout.Foldout(showZoomOptions, "Zoom options", heading); if (showZoomOptions) { GUILayout.Space(10); panoScript.minZoomFov = EditorGUILayout.FloatField("Minimum zoom FOV", panoScript.minZoomFov); panoScript.maxZoomFov = EditorGUILayout.FloatField("Maximum zoom FOV", panoScript.maxZoomFov); GUILayout.Space(10); panoScript.keyboardZoomSpeed = EditorGUILayout.FloatField("Keyboard zoom speed", panoScript.keyboardZoomSpeed); panoScript.touchZoomSpeed = EditorGUILayout.FloatField("Touch zoom speed", panoScript.touchZoomSpeed); panoScript.mouseZoomSpeed = EditorGUILayout.FloatField("Mouse zoom speed", panoScript.mouseZoomSpeed); } GUILayout.Space(10); showRotationOptions = EditorGUILayout.Foldout(showRotationOptions, "Rotation options", heading); if (showRotationOptions) { GUILayout.Space(10); panoScript.limitXRotation = EditorGUILayout.Toggle("Limit horizontal rotation", panoScript.limitXRotation); if (panoScript.limitXRotation) { GUILayout.Space(10); panoScript.maxLeftRotation = EditorGUILayout.FloatField("Maximum left rotation", panoScript.maxLeftRotation); panoScript.maxRightRotation = EditorGUILayout.FloatField("Maximum right rotation", panoScript.maxRightRotation); GUILayout.Space(10); } panoScript.limitYRotation = EditorGUILayout.Toggle("Limit vertical rotation", panoScript.limitYRotation); if (panoScript.limitYRotation) { GUILayout.Space(10); panoScript.maxUpRotation = EditorGUILayout.FloatField("Maximum up rotation", panoScript.maxUpRotation); panoScript.maxDownRotation = EditorGUILayout.FloatField("Maximum down rotation", panoScript.maxDownRotation); GUILayout.Space(10); } if (!panoScript.limitXRotation && !panoScript.limitYRotation) { GUILayout.Space(10); } } else { GUILayout.Space(10); } showPanSpeedOptions = EditorGUILayout.Foldout(showPanSpeedOptions, "Pan speed options", heading); if (showPanSpeedOptions) { GUILayout.Space(10); panoScript.keyboardPanSpeed = EditorGUILayout.FloatField("Keyboard pan speed", panoScript.keyboardPanSpeed); panoScript.touchPanSpeed = EditorGUILayout.FloatField("Touch pan speed", panoScript.touchPanSpeed); panoScript.mousePanSpeed = EditorGUILayout.FloatField("Mouse pan speed", panoScript.mousePanSpeed); } GUILayout.Space(10); showControlInversionOptions = EditorGUILayout.Foldout(showControlInversionOptions, "Control inversion options", heading); if (showControlInversionOptions) { GUILayout.Space(10); panoScript.invertMouseZoom = EditorGUILayout.Toggle("Invert mouse zoom", panoScript.invertMouseZoom); panoScript.invertMouseVertical = EditorGUILayout.Toggle("Invert mouse vertical", panoScript.invertMouseVertical); panoScript.invertMouseHorizontal = EditorGUILayout.Toggle("Invert mouse horizontal", panoScript.invertMouseHorizontal); GUILayout.Space(5); panoScript.invertKeyboardVertical = EditorGUILayout.Toggle("Invert keyboard vertical", panoScript.invertKeyboardVertical); panoScript.invertKeyboardHorizontal = EditorGUILayout.Toggle("Invert keyboard horizontal", panoScript.invertKeyboardHorizontal); GUILayout.Space(5); panoScript.invertTouchVertical = EditorGUILayout.Toggle("Invert touch vertical", panoScript.invertTouchVertical); panoScript.invertTouchHorizontal = EditorGUILayout.Toggle("Invert touch horizontal", panoScript.invertTouchHorizontal); } GUILayout.Space(10); showHotspotOptions = EditorGUILayout.Foldout(showHotspotOptions, "Hotspot options", heading); if (showHotspotOptions) { GUILayout.Space(10); panoScript.hideHotspotsAtStart = EditorGUILayout.Toggle("Hide hotspots at start", panoScript.hideHotspotsAtStart); } GUILayout.Space(20); }
void Start() { panoControls = GetComponent<PanoControls>() ; if(panoControls == null) { Debug.LogError("Couldn't find PanoControls, Please place the GuiControls script on the same object the PanoControls script is attached to") ; } if(guiSkinToUse == null) { Debug.LogWarning("A guiskin hasnt been assigned to the GuiControls script, defaulting to Unity's default skin") ; } // Prevents the user from clicking through the gui element panoControls.useUnityGuiBasedControls = true ; // Adds all the Gui Element Rects to a list, for checking if a touch or click is over a GUI element panoControls.guiButtonRects.Add(panLeftRect) ; panoControls.guiButtonRects.Add(panRightRect) ; panoControls.guiButtonRects.Add(panUpRect) ; panoControls.guiButtonRects.Add(panDownRect) ; panoControls.guiButtonRects.Add(zoomInRect) ; panoControls.guiButtonRects.Add(zoomOutRect) ; }