/// <summary> /// Called when the object should be drawn to the inspector. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> public override void OnInspectorGUI(object target, Object parent) { InspectorUtility.DrawField(target, "m_Target"); InspectorUtility.DrawField(target, "m_Offset"); InspectorUtility.DrawField(target, "m_MinLookDistance"); InspectorUtility.DrawField(target, "m_MaxLookDistance"); InspectorUtility.DrawField(target, "m_MoveSpeed"); InspectorUtility.DrawField(target, "m_RotationalLerpSpeed"); InspectorUtility.DrawField(target, "m_CollisionRadius"); InspectorUtility.DrawSpring(target, "Rotation Spring", "m_RotationSpring"); }
/// <summary> /// Called when the object should be drawn to the inspector. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> public override void OnInspectorGUI(object target, Object parent) { InspectorUtility.DrawField(target, "m_LookDirectionDistance"); InspectorUtility.DrawField(target, "m_ForwardAxis"); InspectorUtility.DrawField(target, "m_LookOffset"); InspectorUtility.DrawField(target, "m_LookOffsetSmoothing"); InspectorUtility.DrawField(target, "m_PositionSmoothing"); InspectorUtility.DrawField(target, "m_ObstructionPositionSmoothing"); InspectorUtility.DrawField(target, "m_UpdateCharacterRotation"); InspectorUtility.DrawFieldSlider(target, "m_AlignToGravityRotationSpeed", 0, 1); InspectorUtility.DrawFieldSlider(target, "m_FieldOfView", 1, 179); InspectorUtility.DrawFieldSlider(target, "m_FieldOfViewDamping", 0, 5); InspectorUtility.DrawField(target, "m_CollisionRadius"); InspectorUtility.DrawField(target, "m_CollisionAnchorOffset"); if (Shared.Editor.Inspectors.Utility.InspectorUtility.Foldout(target, "Primary Spring")) { EditorGUI.indentLevel++; InspectorUtility.DrawSpring(target, "Position Spring", "m_PositionSpring"); InspectorUtility.DrawSpring(target, "Rotation Spring", "m_RotationSpring"); EditorGUI.indentLevel--; } if (Shared.Editor.Inspectors.Utility.InspectorUtility.Foldout(target, "Secondary Spring")) { EditorGUI.indentLevel++; InspectorUtility.DrawSpring(target, "Position Spring", "m_SecondaryPositionSpring"); InspectorUtility.DrawSpring(target, "Rotation Spring", "m_SecondaryRotationSpring"); EditorGUI.indentLevel--; } if (Shared.Editor.Inspectors.Utility.InspectorUtility.Foldout(target, "Step Zoom")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_StepZoomInputName"); InspectorUtility.DrawField(target, "m_StepZoomSensitivity"); InspectorUtility.DrawField(target, "m_MinStepZoom"); InspectorUtility.DrawField(target, "m_MaxStepZoom"); EditorGUI.indentLevel--; } if (Shared.Editor.Inspectors.Utility.InspectorUtility.Foldout(target, "Limits")) { EditorGUI.indentLevel++; OnDrawLimits(target); EditorGUI.indentLevel--; } }
/// <summary> /// Draws the VisibleItem motion properties. /// </summary> protected virtual void DrawMotionProperties() { if (Foldout("Position Spring")) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(PropertyFromName("m_PositionOffset")); GUI.enabled = (target as FirstPersonPerspectiveItem).Object != null; if (GUILayout.Button(Shared.Editor.Inspectors.Utility.InspectorStyles.UpdateIcon, Shared.Editor.Inspectors.Utility.InspectorStyles.NoPaddingButtonStyle, GUILayout.Width(18))) { PropertyFromName("m_PositionOffset").vector3Value = (target as FirstPersonPerspectiveItem).Object.transform.localPosition; GUI.changed = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (Application.isPlaying && GUI.changed) { (target as FirstPersonPerspectiveItem).PositionOffset = PropertyFromName("m_PositionOffset").vector3Value; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(PropertyFromName("m_PositionExitOffset")); GUI.enabled = (target as FirstPersonPerspectiveItem).Object != null; if (GUILayout.Button(Shared.Editor.Inspectors.Utility.InspectorStyles.UpdateIcon, Shared.Editor.Inspectors.Utility.InspectorStyles.NoPaddingButtonStyle, GUILayout.Width(18))) { PropertyFromName("m_PositionExitOffset").vector3Value = (target as FirstPersonPerspectiveItem).Object.transform.localPosition; GUI.changed = true; } GUI.enabled = true; if (Application.isPlaying && GUI.changed) { (target as FirstPersonPerspectiveItem).PositionExitOffset = PropertyFromName("m_PositionExitOffset").vector3Value; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Slider(PropertyFromName("m_PositionFallImpact"), 0, 1); EditorGUILayout.IntSlider(PropertyFromName("m_PositionFallImpactSoftness"), 0, 30); EditorGUILayout.Slider(PropertyFromName("m_PositionFallRetract"), 0, 10); EditorGUILayout.PropertyField(PropertyFromName("m_PositionMoveSlide")); EditorGUILayout.PropertyField(PropertyFromName("m_PositionPlatformSlide")); EditorGUILayout.Slider(PropertyFromName("m_PositionInputVelocityScale"), 0, 10); EditorGUILayout.PropertyField(PropertyFromName("m_PositionMaxInputVelocity")); InspectorUtility.DrawSpring(target, "Spring", "m_PositionSpring"); EditorGUI.indentLevel--; } if (Foldout("Rotation Spring")) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(PropertyFromName("m_RotationOffset")); GUI.enabled = (target as FirstPersonPerspectiveItem).Object != null; if (GUILayout.Button(Shared.Editor.Inspectors.Utility.InspectorStyles.UpdateIcon, Shared.Editor.Inspectors.Utility.InspectorStyles.NoPaddingButtonStyle, GUILayout.Width(18))) { PropertyFromName("m_RotationOffset").vector3Value = (target as FirstPersonPerspectiveItem).Object.transform.localEulerAngles; GUI.changed = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (Application.isPlaying && GUI.changed) { (target as FirstPersonPerspectiveItem).RotationOffset = PropertyFromName("m_RotationOffset").vector3Value; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(PropertyFromName("m_RotationExitOffset")); GUI.enabled = (target as FirstPersonPerspectiveItem).Object != null; if (GUILayout.Button(Shared.Editor.Inspectors.Utility.InspectorStyles.UpdateIcon, Shared.Editor.Inspectors.Utility.InspectorStyles.NoPaddingButtonStyle, GUILayout.Width(18))) { PropertyFromName("m_RotationExitOffset").vector3Value = (target as FirstPersonPerspectiveItem).Object.transform.localEulerAngles; GUI.changed = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (Application.isPlaying && GUI.changed) { (target as FirstPersonPerspectiveItem).RotationExitOffset = PropertyFromName("m_RotationExitOffset").vector3Value; } EditorGUILayout.Slider(PropertyFromName("m_RotationFallImpact"), 0, 100); EditorGUILayout.IntSlider(PropertyFromName("m_RotationFallImpactSoftness"), 0, 30); EditorGUILayout.PropertyField(PropertyFromName("m_RotationLookSway")); EditorGUILayout.PropertyField(PropertyFromName("m_RotationStrafeSway")); EditorGUILayout.PropertyField(PropertyFromName("m_RotationVerticalSway")); EditorGUILayout.PropertyField(PropertyFromName("m_RotationPlatformSway")); EditorGUILayout.Slider(PropertyFromName("m_RotationGroundSwayMultiplier"), 0, 1); EditorGUILayout.Slider(PropertyFromName("m_RotationInputVelocityScale"), 0, 10); EditorGUILayout.PropertyField(PropertyFromName("m_RotationMaxInputVelocity")); InspectorUtility.DrawSpring(target, "Spring", "m_RotationSpring"); EditorGUI.indentLevel--; } if (Foldout("Pivot Position Spring")) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(PropertyFromName("m_PivotPositionOffset")); GUI.enabled = (target as FirstPersonPerspectiveItem).PivotTransform != null; if (GUILayout.Button(Shared.Editor.Inspectors.Utility.InspectorStyles.UpdateIcon, Shared.Editor.Inspectors.Utility.InspectorStyles.NoPaddingButtonStyle, GUILayout.Width(18))) { PropertyFromName("m_PivotPositionOffset").vector3Value = (target as FirstPersonPerspectiveItem).PivotTransform.localPosition; GUI.changed = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (Application.isPlaying && GUI.changed) { (target as FirstPersonPerspectiveItem).PivotPositionOffset = PropertyFromName("m_PivotPositionOffset").vector3Value; } InspectorUtility.DrawSpring(target, "Spring", "m_PivotPositionSpring"); EditorGUI.indentLevel--; } if (Foldout("Pivot Rotation Spring")) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(PropertyFromName("m_PivotRotationOffset")); GUI.enabled = (target as FirstPersonPerspectiveItem).PivotTransform != null; if (GUILayout.Button(Shared.Editor.Inspectors.Utility.InspectorStyles.UpdateIcon, Shared.Editor.Inspectors.Utility.InspectorStyles.NoPaddingButtonStyle, GUILayout.Width(18))) { PropertyFromName("m_PivotRotationOffset").vector3Value = (target as FirstPersonPerspectiveItem).PivotTransform.localEulerAngles; GUI.changed = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (Application.isPlaying && GUI.changed) { (target as FirstPersonPerspectiveItem).PivotRotationOffset = PropertyFromName("m_PivotRotationOffset").vector3Value; } InspectorUtility.DrawSpring(target, "Spring", "m_PivotRotationSpring"); EditorGUI.indentLevel--; } if (Foldout("Shake")) { EditorGUI.indentLevel++; EditorGUILayout.Slider(PropertyFromName("m_ShakeSpeed"), 0, 10); EditorGUILayout.PropertyField(PropertyFromName("m_ShakeAmplitude")); EditorGUI.indentLevel--; } if (Foldout("Bob")) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(PropertyFromName("m_BobPositionalRate")); EditorGUILayout.PropertyField(PropertyFromName("m_BobPositionalAmplitude")); EditorGUILayout.PropertyField(PropertyFromName("m_BobRotationalRate")); EditorGUILayout.PropertyField(PropertyFromName("m_BobRotationalAmplitude")); EditorGUILayout.Slider(PropertyFromName("m_BobInputVelocityScale"), 0, 10); EditorGUILayout.PropertyField(PropertyFromName("m_BobMaxInputVelocity")); EditorGUILayout.PropertyField(PropertyFromName("m_BobRequireGroundContact")); EditorGUI.indentLevel--; } if (Foldout("Step")) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(PropertyFromName("m_StepMinVelocity")); EditorGUILayout.IntSlider(PropertyFromName("m_StepSoftness"), 0, 30); EditorGUILayout.PropertyField(PropertyFromName("m_StepPositionForce")); EditorGUILayout.PropertyField(PropertyFromName("m_StepRotationForce")); EditorGUILayout.Slider(PropertyFromName("m_StepForceScale"), 0, 1); EditorGUILayout.Slider(PropertyFromName("m_StepPositionBalance"), -1, 1); EditorGUILayout.Slider(PropertyFromName("m_StepRotationBalance"), -1, 1); EditorGUI.indentLevel--; } }
/// <summary> /// Called when the object should be drawn to the inspector. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> public override void OnInspectorGUI(object target, Object parent) { // Draw the fields related to rendering. if (InspectorUtility.Foldout(target, "Rendering")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_LookDirectionDistance"); var lookOffsetValue = InspectorUtility.GetFieldValue <Vector3>(target, "m_LookOffset"); var lookOffset = EditorGUILayout.Vector3Field(new GUIContent(InspectorUtility.SplitCamelCase("m_LookOffset"), InspectorUtility.GetFieldTooltip(target, "m_LookOffset")), lookOffsetValue); // Set the property if the game is playing so the camera will update. if (lookOffsetValue != lookOffset) { (target as FirstPerson).LookOffset = lookOffset; InspectorUtility.SetFieldValue(target, "m_LookOffset", lookOffset); } InspectorUtility.DrawField(target, "m_LookDownOffset"); InspectorUtility.DrawField(target, "m_CullingMask"); InspectorUtility.DrawFieldSlider(target, "m_FieldOfView", 1, 179); InspectorUtility.DrawFieldSlider(target, "m_FieldOfViewDamping", 0, 5); #if ULTIMATE_CHARACTER_CONTROLLER_LWRP || ULTIMATE_CHARACTER_CONTROLLER_UNIVERSALRP var prevRenderType = InspectorUtility.GetFieldValue <FirstPerson.ObjectOverlayRenderType>(target, "m_OverlayRenderType"); InspectorUtility.DrawField(target, "m_OverlayRenderType"); var renderType = InspectorUtility.GetFieldValue <FirstPerson.ObjectOverlayRenderType>(target, "m_OverlayRenderType"); // Ensure the render type has been switched for all first person view types. if (prevRenderType != renderType) { if (renderType == FirstPerson.ObjectOverlayRenderType.SecondCamera) { UltimateCharacterController.Utility.Builders.ViewTypeBuilder.AddFirstPersonCamera(parent as CameraController, target as FirstPerson); } else if (prevRenderType == FirstPerson.ObjectOverlayRenderType.SecondCamera) { var firstPersonCamera = InspectorUtility.GetFieldValue <UnityEngine.Camera>(target, "m_FirstPersonCamera"); if (firstPersonCamera != null) { if (PrefabUtility.IsPartOfPrefabInstance(firstPersonCamera.gameObject)) { PrefabUtility.UnpackPrefabInstance(PrefabUtility.GetOutermostPrefabInstanceRoot(firstPersonCamera.gameObject), PrefabUnpackMode.Completely, InteractionMode.AutomatedAction); } GameObject.DestroyImmediate(firstPersonCamera.gameObject, true); (target as FirstPerson).FirstPersonCamera = null; } } // All first person view types need to be switched to the currently active render type. var viewTypes = (parent as CameraController).ViewTypes; for (int i = 0; i < viewTypes.Length; ++i) { var firstPersonViewType = viewTypes[i] as FirstPerson; if (firstPersonViewType == null) { continue; } if (renderType == FirstPerson.ObjectOverlayRenderType.RenderPipeline && firstPersonViewType.OverlayRenderType == FirstPerson.ObjectOverlayRenderType.SecondCamera) { firstPersonViewType.FirstPersonCamera = null; firstPersonViewType.OverlayRenderType = renderType; } else if (renderType == FirstPerson.ObjectOverlayRenderType.SecondCamera && firstPersonViewType.OverlayRenderType == FirstPerson.ObjectOverlayRenderType.RenderPipeline) { firstPersonViewType.FirstPersonCamera = (target as FirstPerson).FirstPersonCamera; firstPersonViewType.OverlayRenderType = renderType; } } UltimateCharacterController.Utility.Builders.ViewTypeBuilder.SerializeViewTypes(parent as CameraController); } var drawFirstPersonCamera = renderType == FirstPerson.ObjectOverlayRenderType.SecondCamera; #else InspectorUtility.DrawField(target, "m_UseFirstPersonCamera"); var drawFirstPersonCamera = InspectorUtility.GetFieldValue <bool>(target, "m_UseFirstPersonCamera"); #endif if (drawFirstPersonCamera && InspectorUtility.Foldout(target, "First Person Camera")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_FirstPersonCamera"); InspectorUtility.DrawField(target, "m_FirstPersonCullingMask"); InspectorUtility.DrawField(target, "m_SynchronizeFieldOfView"); var synchronizeFieldOfView = InspectorUtility.GetFieldValue <bool>(target, "m_SynchronizeFieldOfView"); if (!synchronizeFieldOfView) { InspectorUtility.DrawFieldSlider(target, "m_FirstPersonFieldOfView", 1, 179); InspectorUtility.DrawFieldSlider(target, "m_FirstPersonFieldOfViewDamping", 0, 5); } var positionOffsetValue = InspectorUtility.GetFieldValue <Vector3>(target, "m_FirstPersonPositionOffset"); var positionOffset = EditorGUILayout.Vector3Field(new GUIContent(InspectorUtility.SplitCamelCase("m_FirstPersonPositionOffset"), InspectorUtility.GetFieldTooltip(target, "m_FirstPersonPositionOffset")), positionOffsetValue); // Set the property if the game is playing so the camera will update. if (positionOffsetValue != positionOffset) { (target as FirstPerson).FirstPersonPositionOffset = positionOffset; InspectorUtility.SetFieldValue(target, "m_FirstPersonPositionOffset", positionOffset); } var rotationOffsetValue = InspectorUtility.GetFieldValue <Vector3>(target, "m_FirstPersonRotationOffset"); var rotationOffset = EditorGUILayout.Vector3Field(new GUIContent(InspectorUtility.SplitCamelCase("m_FirstPersonRotationOffset"), InspectorUtility.GetFieldTooltip(target, "m_FirstPersonRotationOffset")), rotationOffsetValue); // Set the property so the camera will update. if (rotationOffsetValue != rotationOffset) { (target as FirstPerson).FirstPersonRotationOffset = rotationOffset; InspectorUtility.SetFieldValue(target, "m_FirstPersonRotationOffset", rotationOffset); } EditorGUI.indentLevel--; } #if ULTIMATE_CHARACTER_CONTROLLER_LWRP || ULTIMATE_CHARACTER_CONTROLLER_UNIVERSALRP else if (renderType == FirstPerson.ObjectOverlayRenderType.RenderPipeline) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_FirstPersonCullingMask"); EditorGUI.indentLevel--; } #endif EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Primary Spring")) { EditorGUI.indentLevel++; InspectorUtility.DrawSpring(target, "Position Spring", "m_PositionSpring"); var lowerLimit = InspectorUtility.GetFieldValue <float>(target, "m_PositionLowerVerticalLimit"); var lowerLimitValue = EditorGUILayout.Slider(new GUIContent(InspectorUtility.SplitCamelCase("m_PositionLowerVerticalLimit"), InspectorUtility.GetFieldTooltip(target, "m_PositionLowerVerticalLimit")), lowerLimit, 0, 5); // Set the property if the game is playing so the camera will update. if (lowerLimitValue != lowerLimit) { (target as FirstPerson).PositionLowerVerticalLimit = lowerLimit; InspectorUtility.SetFieldValue(target, "m_PositionLowerVerticalLimit", lowerLimitValue); } InspectorUtility.DrawFieldSlider(target, "m_PositionFallImpact", 0, 5); InspectorUtility.DrawFieldIntSlider(target, "m_PositionFallImpactSoftness", 1, 30); InspectorUtility.DrawFieldSlider(target, "m_RotationStrafeRoll", -5, 5); InspectorUtility.DrawSpring(target, "Rotation Spring", "m_RotationSpring"); InspectorUtility.DrawFieldSlider(target, "m_RotationFallImpact", 0, 5); InspectorUtility.DrawFieldIntSlider(target, "m_RotationFallImpactSoftness", 1, 30); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Secondary Spring")) { EditorGUI.indentLevel++; InspectorUtility.DrawSpring(target, "Secondary Position Spring", "m_SecondaryPositionSpring"); InspectorUtility.DrawSpring(target, "Secondary Rotation Spring", "m_SecondaryRotationSpring"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Shake")) { EditorGUI.indentLevel++; InspectorUtility.DrawFieldSlider(target, "m_ShakeSpeed", 0, 10); InspectorUtility.DrawField(target, "m_ShakeAmplitude"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Bob")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_BobPositionalRate"); InspectorUtility.DrawField(target, "m_BobPositionalAmplitude"); InspectorUtility.DrawField(target, "m_BobRollRate"); InspectorUtility.DrawField(target, "m_BobRollAmplitude"); InspectorUtility.DrawFieldSlider(target, "m_BobInputVelocityScale", 0, 10); InspectorUtility.DrawField(target, "m_BobMaxInputVelocity"); InspectorUtility.DrawField(target, "m_BobMinTroughVerticalOffset"); InspectorUtility.DrawField(target, "m_BobTroughForce"); InspectorUtility.DrawField(target, "m_BobRequireGroundContact"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Limits")) { EditorGUI.indentLevel++; var minPitchLimit = InspectorUtility.GetFieldValue <float>(target, "m_MinPitchLimit"); var maxPitchLimit = InspectorUtility.GetFieldValue <float>(target, "m_MaxPitchLimit"); var minValue = Mathf.Round(minPitchLimit * 100f) / 100f; var maxValue = Mathf.Round(maxPitchLimit * 100f) / 100f; InspectorUtility.MinMaxSlider(ref minValue, ref maxValue, -90, 90, new GUIContent("Pitch Limit", "The min and max limit of the pitch angle (in degrees).")); if (minValue != minPitchLimit) { InspectorUtility.SetFieldValue(target, "m_MinPitchLimit", minValue); } if (minValue != maxPitchLimit) { InspectorUtility.SetFieldValue(target, "m_MaxPitchLimit", maxValue); } if (target is FreeLook) { var minYawLimit = InspectorUtility.GetFieldValue <float>(target, "m_MinYawLimit"); var maxYawLimit = InspectorUtility.GetFieldValue <float>(target, "m_MaxYawLimit"); minValue = Mathf.Round(minYawLimit * 100f) / 100f; maxValue = Mathf.Round(maxYawLimit * 100f) / 100f; InspectorUtility.MinMaxSlider(ref minValue, ref maxValue, -180, 180, new GUIContent("Yaw Limit", "The min and max limit of the yaw angle (in degrees).")); if (minValue != minYawLimit) { InspectorUtility.SetFieldValue(target, "m_MinYawLimit", minValue); } if (minValue != maxYawLimit) { InspectorUtility.SetFieldValue(target, "m_MaxYawLimit", maxValue); } InspectorUtility.DrawField(target, "m_YawLimitLerpSpeed"); InspectorUtility.DrawField(target, "m_RotateWithCharacter"); } InspectorUtility.DrawField(target, "m_LookDirectionDistance"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Head Tracking")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_SmoothHeadOffsetSteps"); InspectorUtility.DrawField(target, "m_CollisionRadius"); InspectorUtility.DrawField(target, "m_RotateWithHead"); EditorGUI.indentLevel--; } }
/// <summary> /// Called when the object should be drawn to the inspector. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> public override void OnInspectorGUI(object target, Object parent) { // Draw the fields related to rendering. if (InspectorUtility.Foldout(target, "Rendering")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_LookDirectionDistance"); var lookOffsetValue = InspectorUtility.GetFieldValue <Vector3>(target, "m_LookOffset"); var lookOffset = EditorGUILayout.Vector3Field(new GUIContent(InspectorUtility.SplitCamelCase("m_LookOffset"), InspectorUtility.GetFieldTooltip(target, "m_LookOffset")), lookOffsetValue); // Set the property if the game is playing so the camera will update. if (lookOffsetValue != lookOffset) { (target as FirstPerson).LookOffset = lookOffset; InspectorUtility.SetFieldValue(target, "m_LookOffset", lookOffset); } InspectorUtility.DrawField(target, "m_LookDownOffset"); InspectorUtility.DrawField(target, "m_CullingMask"); InspectorUtility.DrawFieldSlider(target, "m_FieldOfView", 1, 179); InspectorUtility.DrawFieldSlider(target, "m_FieldOfViewDamping", 0, 5); if (InspectorUtility.Foldout(target, "First Person Camera")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_UseFirstPersonCamera"); InspectorUtility.DrawField(target, "m_FirstPersonCamera"); InspectorUtility.DrawField(target, "m_FirstPersonCullingMask"); InspectorUtility.DrawField(target, "m_SynchronizeFieldOfView"); var synchronizeFieldOfView = InspectorUtility.GetFieldValue <bool>(target, "m_SynchronizeFieldOfView"); if (!synchronizeFieldOfView) { InspectorUtility.DrawFieldSlider(target, "m_FirstPersonFieldOfView", 1, 179); InspectorUtility.DrawFieldSlider(target, "m_FirstPersonFieldOfViewDamping", 0, 5); } var positionOffsetValue = InspectorUtility.GetFieldValue <Vector3>(target, "m_FirstPersonPositionOffset"); var positionOffset = EditorGUILayout.Vector3Field(new GUIContent(InspectorUtility.SplitCamelCase("m_FirstPersonPositionOffset"), InspectorUtility.GetFieldTooltip(target, "m_FirstPersonPositionOffset")), positionOffsetValue); // Set the property if the game is playing so the camera will update. if (positionOffsetValue != positionOffset) { (target as FirstPerson).FirstPersonPositionOffset = positionOffset; InspectorUtility.SetFieldValue(target, "m_FirstPersonPositionOffset", positionOffset); } var rotationOffsetValue = InspectorUtility.GetFieldValue <Vector3>(target, "m_FirstPersonRotationOffset"); var rotationOffset = EditorGUILayout.Vector3Field(new GUIContent(InspectorUtility.SplitCamelCase("m_FirstPersonRotationOffset"), InspectorUtility.GetFieldTooltip(target, "m_FirstPersonRotationOffset")), rotationOffsetValue); // Set the property so the camera will update. if (rotationOffsetValue != rotationOffset) { (target as FirstPerson).FirstPersonRotationOffset = rotationOffset; InspectorUtility.SetFieldValue(target, "m_FirstPersonRotationOffset", rotationOffset); } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Primary Spring")) { EditorGUI.indentLevel++; InspectorUtility.DrawSpring(target, "Position Spring", "m_PositionSpring"); var lowerLimit = InspectorUtility.GetFieldValue <float>(target, "m_PositionLowerVerticalLimit"); var lowerLimitValue = EditorGUILayout.Slider(new GUIContent(InspectorUtility.SplitCamelCase("m_PositionLowerVerticalLimit"), InspectorUtility.GetFieldTooltip(target, "m_PositionLowerVerticalLimit")), lowerLimit, 0, 5); // Set the property if the game is playing so the camera will update. if (lowerLimitValue != lowerLimit) { (target as FirstPerson).PositionLowerVerticalLimit = lowerLimit; InspectorUtility.SetFieldValue(target, "m_PositionLowerVerticalLimit", lowerLimitValue); } InspectorUtility.DrawFieldSlider(target, "m_PositionFallImpact", 0, 5); InspectorUtility.DrawFieldIntSlider(target, "m_PositionFallImpactSoftness", 1, 30); InspectorUtility.DrawFieldSlider(target, "m_RotationStrafeRoll", -5, 5); InspectorUtility.DrawSpring(target, "Rotation Spring", "m_RotationSpring"); InspectorUtility.DrawFieldSlider(target, "m_RotationFallImpact", 0, 5); InspectorUtility.DrawFieldIntSlider(target, "m_RotationFallImpactSoftness", 1, 30); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Secondary Spring")) { EditorGUI.indentLevel++; InspectorUtility.DrawSpring(target, "Secondary Position Spring", "m_SecondaryPositionSpring"); InspectorUtility.DrawSpring(target, "Secondary Rotation Spring", "m_SecondaryRotationSpring"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Shake")) { EditorGUI.indentLevel++; InspectorUtility.DrawFieldSlider(target, "m_ShakeSpeed", 0, 10); InspectorUtility.DrawField(target, "m_ShakeAmplitude"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Bob")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_BobPositionalRate"); InspectorUtility.DrawField(target, "m_BobPositionalAmplitude"); InspectorUtility.DrawField(target, "m_BobRollRate"); InspectorUtility.DrawField(target, "m_BobRollAmplitude"); InspectorUtility.DrawFieldSlider(target, "m_BobInputVelocityScale", 0, 10); InspectorUtility.DrawField(target, "m_BobMaxInputVelocity"); InspectorUtility.DrawField(target, "m_BobMinTroughVerticalOffset"); InspectorUtility.DrawField(target, "m_BobTroughForce"); InspectorUtility.DrawField(target, "m_BobRequireGroundContact"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Limits")) { EditorGUI.indentLevel++; var minPitchLimit = InspectorUtility.GetFieldValue <float>(target, "m_MinPitchLimit"); var maxPitchLimit = InspectorUtility.GetFieldValue <float>(target, "m_MaxPitchLimit"); var minValue = Mathf.Round(minPitchLimit * 100f) / 100f; var maxValue = Mathf.Round(maxPitchLimit * 100f) / 100f; InspectorUtility.MinMaxSlider(ref minValue, ref maxValue, -90, 90, new GUIContent("Pitch Limit", "The min and max limit of the pitch angle (in degrees).")); if (minValue != minPitchLimit) { InspectorUtility.SetFieldValue(target, "m_MinPitchLimit", minValue); } if (minValue != maxPitchLimit) { InspectorUtility.SetFieldValue(target, "m_MaxPitchLimit", maxValue); } if (target is FreeLook) { var minYawLimit = InspectorUtility.GetFieldValue <float>(target, "m_MinYawLimit"); var maxYawLimit = InspectorUtility.GetFieldValue <float>(target, "m_MaxYawLimit"); minValue = Mathf.Round(minYawLimit * 100f) / 100f; maxValue = Mathf.Round(maxYawLimit * 100f) / 100f; InspectorUtility.MinMaxSlider(ref minValue, ref maxValue, -180, 180, new GUIContent("Yaw Limit", "The min and max limit of the yaw angle (in degrees).")); if (minValue != minYawLimit) { InspectorUtility.SetFieldValue(target, "m_MinYawLimit", minValue); } if (minValue != maxYawLimit) { InspectorUtility.SetFieldValue(target, "m_MaxYawLimit", maxValue); } InspectorUtility.DrawField(target, "m_YawLimitLerpSpeed"); } InspectorUtility.DrawField(target, "m_LookDirectionDistance"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "Head Tracking")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_SmoothHeadOffsetSteps"); InspectorUtility.DrawField(target, "m_CollisionRadius"); InspectorUtility.DrawField(target, "m_RotateWithHead"); EditorGUI.indentLevel--; } }
/// <summary> /// Called when the object should be drawn to the inspector. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> public override void OnInspectorGUI(object target, Object parent) { InspectorUtility.DrawField(target, "m_LookDirectionDistance"); InspectorUtility.DrawField(target, "m_ForwardAxis"); InspectorUtility.DrawField(target, "m_UpAxis"); InspectorUtility.DrawFieldSlider(target, "m_FieldOfView", 1, 179); InspectorUtility.DrawFieldSlider(target, "m_FieldOfViewDamping", 0, 5); InspectorUtility.DrawField(target, "m_RotationSpeed"); InspectorUtility.DrawField(target, "m_CollisionRadius"); InspectorUtility.DrawField(target, "m_ViewDistance"); InspectorUtility.DrawField(target, "m_ViewStep"); InspectorUtility.DrawField(target, "m_VerticalLookDirection"); var minPitchLimit = InspectorUtility.GetFieldValue <float>(target, "m_MinPitchLimit"); var maxPitchLimit = InspectorUtility.GetFieldValue <float>(target, "m_MaxPitchLimit"); var minValue = Mathf.Round(minPitchLimit * 100f) / 100f; var maxValue = Mathf.Round(maxPitchLimit * 100f) / 100f; InspectorUtility.MinMaxSlider(ref minValue, ref maxValue, 0, 89.99f, new GUIContent("Pitch Limit", "The min and max limit of the pitch angle (in degrees).")); if (minValue != minPitchLimit) { InspectorUtility.SetFieldValue(target, "m_MinPitchLimit", minValue); } if (minValue != maxPitchLimit) { InspectorUtility.SetFieldValue(target, "m_MaxPitchLimit", maxValue); } InspectorUtility.DrawField(target, "m_AllowDynamicCameraRotation"); var dynamicRotation = InspectorUtility.GetFieldValue <bool>(target, "m_AllowDynamicCameraRotation"); if (dynamicRotation) { UnityEditor.EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_DesiredAngle"); InspectorUtility.DrawField(target, "m_ChangeAngleSpeed"); InspectorUtility.DrawField(target, "m_RotationTransitionCurve"); UnityEditor.EditorGUI.indentLevel--; } InspectorUtility.DrawField(target, "m_AllowDynamicPitchAdjustment"); var pitchAdjustment = InspectorUtility.GetFieldValue <bool>(target, "m_AllowDynamicPitchAdjustment"); if (pitchAdjustment) { UnityEditor.EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_DesiredPitch"); InspectorUtility.DrawField(target, "m_ChangePitchSpeed"); InspectorUtility.DrawField(target, "m_UseIndependentPitchTransition"); var pitchTransition = InspectorUtility.GetFieldValue <bool>(target, "m_UseIndependentPitchTransition"); if (pitchTransition) { InspectorUtility.DrawField(target, "m_PitchTransitionCurve"); } UnityEditor.EditorGUI.indentLevel--; } InspectorUtility.DrawField(target, "m_AllowDynamicDistanceAdjustment"); var distanceAdjustment = InspectorUtility.GetFieldValue <bool>(target, "m_AllowDynamicDistanceAdjustment"); if (pitchAdjustment) { UnityEditor.EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_DesiredDistance"); InspectorUtility.DrawField(target, "m_ChangeDistanceSpeed"); InspectorUtility.DrawField(target, "m_UseIndependentDistanceTransition"); var distanceTransition = InspectorUtility.GetFieldValue <bool>(target, "m_UseIndependentDistanceTransition"); if (distanceTransition) { InspectorUtility.DrawField(target, "m_DistanceTransitionCurve"); } UnityEditor.EditorGUI.indentLevel--; } if (Shared.Editor.Inspectors.Utility.InspectorUtility.Foldout(target, "Secondary Spring")) { UnityEditor.EditorGUI.indentLevel++; InspectorUtility.DrawSpring(target, "Secondary Position Spring", "m_SecondaryPositionSpring"); InspectorUtility.DrawSpring(target, "Secondary Rotation Spring", "m_SecondaryRotationSpring"); UnityEditor.EditorGUI.indentLevel--; } }