/// <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_ParticlePrefab"); InspectorUtility.DrawField(target, "m_PositionOffset"); InspectorUtility.DrawField(target, "m_RotationOffset"); InspectorUtility.DrawField(target, "m_ParentToOrigin"); InspectorUtility.DrawField(target, "m_ProjectDirectionOnPlane"); InspectorUtility.DrawField(target, "m_ClearParentOnStop"); InspectorUtility.DrawField(target, "m_SetRendererLengthScale"); var spawnParticle = target as SpawnParticle; if (spawnParticle.SetRendererLengthScale) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_AdditionalLength"); EditorGUI.indentLevel--; } spawnParticle.ParticleLayer = EditorGUILayout.LayerField(new GUIContent("Particle Layer", "The layer that the particle should occupy."), spawnParticle.ParticleLayer); InspectorUtility.DrawField(target, "m_FadeInDuration"); InspectorUtility.DrawField(target, "m_FadeOutDuration"); if (spawnParticle.FadeInDuration > 0 || spawnParticle.FadeOutDuration > 0) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_MaterialColorName"); InspectorUtility.DrawField(target, "m_FadeStep"); EditorGUI.indentLevel--; } }
/// <summary> /// Draws the fields related to the inspector drawer. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> protected override void DrawInspectorDrawerFields(object target, Object parent) { m_Jump = target as Jump; InspectorUtility.DrawField(target, "m_MinCeilingJumpHeight"); InspectorUtility.DrawField(target, "m_GroundedGracePeriod"); InspectorUtility.DrawField(target, "m_Force"); InspectorUtility.DrawField(target, "m_SidewaysForceMultiplier"); InspectorUtility.DrawField(target, "m_BackwardsForceMultiplier"); InspectorUtility.DrawField(target, "m_Frames"); InspectorUtility.DrawField(target, "m_JumpEvent"); InspectorUtility.DrawField(target, "m_JumpSurfaceImpact"); InspectorUtility.DrawField(target, "m_ForceHold"); InspectorUtility.DrawField(target, "m_ForceDampingHold"); InspectorUtility.DrawField(target, "m_MaxRepeatedJumpCount"); if (m_Jump.MaxRepeatedJumpCount > 0) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_RepeatedJumpForce"); InspectorUtility.DrawField(target, "m_RepeatedJumpFrames"); if (InspectorUtility.Foldout(target, "Repeated Jump Audio")) { EditorGUI.indentLevel++; m_ReorderableRepeatedJumpAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_Jump.RepeatedJumpAudioClipSet, null, m_ReorderableRepeatedJumpAudioClipsList, OnRepeatedJumpAudioClipDraw, OnRepeatedJumpAudioClipListAdd, OnRepeatedJumpAudioClipListRemove); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } InspectorUtility.DrawField(target, "m_VerticalVelocityStopThreshold"); InspectorUtility.DrawField(target, "m_RecurrenceDelay"); }
/// <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.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); } }
/// <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) { base.OnInspectorGUI(target, parent); if (InspectorUtility.Foldout(target, "RPG")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_YawSnapDamping"); InspectorUtility.DrawField(target, "m_AllowFreeMovement"); InspectorUtility.DrawField(target, "m_CameraFreeMovementInputName"); 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) { var effectValue = InspectorUtility.GetFieldValue <string>(target, "m_EffectName"); var newEffectValue = InspectorUtility.DrawTypePopup(typeof(UltimateCharacterController.Character.Effects.Effect), effectValue, "Effect", true); if (effectValue != newEffectValue) { InspectorUtility.SetFieldValue(target, "m_EffectName", newEffectValue); InspectorUtility.SetDirty(parent); } InspectorUtility.DrawField(target, "m_EffectIndex"); InspectorUtility.DrawField(target, "m_StopEffect"); }
/// <summary> /// Draws the fields related to the inspector drawer. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> protected override void DrawInspectorDrawerFields(object target, Object parent) { // Draw ObjectDetectionMode manually so it'll use the MaskField. var objectDetection = (int)InspectorUtility.GetFieldValue <DetectObjectAbilityBase.ObjectDetectionMode>(target, "m_ObjectDetection"); var objectDetectionString = System.Enum.GetNames(typeof(DetectObjectAbilityBase.ObjectDetectionMode)); var value = EditorGUILayout.MaskField(new GUIContent("Object Detection", InspectorUtility.GetFieldTooltip(target, "m_ObjectDetection")), objectDetection, objectDetectionString); if (value != objectDetection) { InspectorUtility.SetFieldValue(target, "m_ObjectDetection", value); } // The ability may not use any detection. if (value != 0) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_DetectLayers"); InspectorUtility.DrawField(target, "m_UseLookPosition"); InspectorUtility.DrawField(target, "m_UseLookDirection"); InspectorUtility.DrawField(target, "m_AngleThreshold"); InspectorUtility.DrawField(target, "m_ObjectID"); var objectDetectionEnumValue = (DetectObjectAbilityBase.ObjectDetectionMode)value; if (objectDetectionEnumValue != DetectObjectAbilityBase.ObjectDetectionMode.Trigger) { InspectorUtility.DrawField(target, "m_CastDistance"); InspectorUtility.DrawField(target, "m_CastFrameInterval"); InspectorUtility.DrawField(target, "m_CastOffset"); InspectorUtility.DrawField(target, "m_TriggerInteraction"); if ((objectDetectionEnumValue & DetectObjectAbilityBase.ObjectDetectionMode.Spherecast) != 0) { InspectorUtility.DrawField(target, "m_SpherecastRadius"); } } if ((objectDetectionEnumValue & DetectObjectAbilityBase.ObjectDetectionMode.Trigger) != 0) { InspectorUtility.DrawField(target, "m_MaxTriggerObjectCount"); } if (EditorApplication.isPlaying) { var detectObjectAbility = (DetectObjectAbilityBase)target; EditorGUILayout.LabelField("Detected Object", detectObjectAbility.DetectedObject != null ? detectObjectAbility.DetectedObject.name : "(none)"); } EditorGUI.indentLevel--; } InspectorUtility.DrawField(target, "m_MoveWithObject"); base.DrawInspectorDrawerFields(target, parent); }
/// <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> /// 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_Mode"); InspectorUtility.DrawField(target, "m_UseLookSourcePosition"); InspectorUtility.DrawField(target, "m_PositionOffset"); var mode = (target as PhysicsCast).Mode; if (mode != PhysicsCast.CastMode.OverlapSphere) { InspectorUtility.DrawField(target, "m_Distance"); } if (mode != PhysicsCast.CastMode.Raycast) { InspectorUtility.DrawField(target, "m_Radius"); } InspectorUtility.DrawField(target, "m_Layers"); InspectorUtility.DrawField(target, "m_MaxCollisionCount"); InspectorUtility.DrawField(target, "m_TriggerInteraction"); }
/// <summary> /// Callback which draws the limits for the view type. /// </summary> /// <param name="target">The object that is being drawn.</param> protected override void OnDrawLimits(object target) { base.OnDrawLimits(target); var minYawLimit = InspectorUtility.GetFieldValue <float>(target, "m_MinYawLimit"); var maxYawLimit = InspectorUtility.GetFieldValue <float>(target, "m_MaxYawLimit"); var minValue = Mathf.Round(minYawLimit * 100f) / 100f; var 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"); }
/// <summary> /// Draws the fields related to the inspector drawer. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> protected override void DrawInspectorDrawerFields(object target, UnityEngine.Object parent) { InspectorUtility.DrawField(target, "m_StartOnDeath"); InspectorUtility.DrawField(target, "m_StartDelay"); var ragdollLayerFieldValue = InspectorUtility.GetFieldValue <int>(target, "m_RagdollLayer"); var value = EditorGUILayout.LayerField(new GUIContent("Ragdoll Layer", InspectorUtility.GetFieldTooltip(target, "m_RagdollLayer")), ragdollLayerFieldValue); if (ragdollLayerFieldValue != value) { InspectorUtility.SetFieldValue(target, "m_RagdollLayer", value); } ragdollLayerFieldValue = InspectorUtility.GetFieldValue <int>(target, "m_InactiveRagdollLayer"); value = EditorGUILayout.LayerField(new GUIContent("Inactive Ragdoll Layer", InspectorUtility.GetFieldTooltip(target, "m_InactiveRagdollLayer")), ragdollLayerFieldValue); if (ragdollLayerFieldValue != value) { InspectorUtility.SetFieldValue(target, "m_InactiveRagdollLayer", value); } InspectorUtility.DrawField(target, "m_CameraRotationalForce"); base.DrawInspectorDrawerFields(target, parent); }
/// <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) { DrawInspectorDrawerFields(target, parent); InspectorUtility.DrawField(target, "m_InspectorDescription"); }
/// <summary> /// Draws the fields related to the inspector drawer. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> protected override void DrawInspectorDrawerFields(object target, Object parent) { var restriction = (RestrictPosition.RestrictionType)EditorGUILayout.EnumPopup(new GUIContent("Restriction", InspectorUtility.GetFieldTooltip(target, "m_Restriction")), InspectorUtility.GetFieldValue <RestrictPosition.RestrictionType>(target, "m_Restriction")); InspectorUtility.SetFieldValue(target, "m_Restriction", restriction); // Draw the x restriction. if (restriction != RestrictPosition.RestrictionType.RestrictZ) { EditorGUI.indentLevel++; var minValue = InspectorUtility.GetFieldValue <float>(target, "m_MinXPosition"); var maxValue = InspectorUtility.GetFieldValue <float>(target, "m_MaxXPosition"); minValue = EditorGUILayout.FloatField(new GUIContent("Min X Position", InspectorUtility.GetFieldTooltip(target, "m_MinXPosition")), minValue); if (minValue > maxValue) { maxValue = minValue; } maxValue = EditorGUILayout.FloatField(new GUIContent("Max X Position", InspectorUtility.GetFieldTooltip(target, "m_MaxXPosition")), maxValue); if (maxValue < minValue) { minValue = maxValue; } InspectorUtility.SetFieldValue(target, "m_MinXPosition", minValue); InspectorUtility.SetFieldValue(target, "m_MaxXPosition", maxValue); EditorGUI.indentLevel--; } // Draw the z restriction. if (restriction != RestrictPosition.RestrictionType.RestrictX) { EditorGUI.indentLevel++; var minValue = InspectorUtility.GetFieldValue <float>(target, "m_MinZPosition"); var maxValue = InspectorUtility.GetFieldValue <float>(target, "m_MaxZPosition"); minValue = EditorGUILayout.FloatField(new GUIContent("Min Z Position", InspectorUtility.GetFieldTooltip(target, "m_MinZPosition")), minValue); if (minValue > maxValue) { maxValue = minValue; } maxValue = EditorGUILayout.FloatField(new GUIContent("Max Z Position", InspectorUtility.GetFieldTooltip(target, "m_MaxZPosition")), maxValue); if (maxValue < minValue) { minValue = maxValue; } InspectorUtility.SetFieldValue(target, "m_MinZPosition", minValue); InspectorUtility.SetFieldValue(target, "m_MaxZPosition", maxValue); EditorGUI.indentLevel--; } var stopAnimation = EditorGUILayout.Toggle(new GUIContent("Stop Animation", InspectorUtility.GetFieldTooltip(target, "m_StopAnimation")), InspectorUtility.GetFieldValue <bool>(target, "m_StopAnimation")); InspectorUtility.SetFieldValue(target, "m_StopAnimation", stopAnimation); if (stopAnimation) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_StopAnimationBuffer"); EditorGUI.indentLevel--; } base.DrawInspectorDrawerFields(target, parent); }
/// <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) { m_Ability = (target as Ability); DrawInputFieldsFields(target, parent); InspectorUtility.DrawAttributeModifier((parent as Component).GetComponent <AttributeManager>(), (target as Ability).AttributeModifier, "Attribute Name"); EditorGUILayout.BeginHorizontal(); InspectorUtility.DrawField(target, "m_State"); GUI.enabled = !string.IsNullOrEmpty(InspectorUtility.GetFieldValue <string>(target, "m_State")); // The InspectorUtility doesn't support a toggle with the text on the right. var field = InspectorUtility.GetField(target, "m_StateAppendItemIdentifierName"); GUILayout.Space(-5); var value = EditorGUILayout.ToggleLeft(new GUIContent("Append Item", InspectorUtility.GetFieldTooltip(field)), (bool)field.GetValue(target), GUILayout.Width(110)); InspectorUtility.SetFieldValue(target, "m_StateAppendItemIdentifierName", value); GUI.enabled = true; EditorGUILayout.EndHorizontal(); InspectorUtility.DrawField(target, "m_AbilityIndexParameter"); DrawInspectorDrawerFields(target, parent); if (InspectorUtility.Foldout(target, "Audio")) { EditorGUI.indentLevel++; if (InspectorUtility.Foldout(target, "Start")) { EditorGUI.indentLevel++; m_ReorderableStartAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_Ability.StartAudioClipSet, null, m_ReorderableStartAudioClipsList, OnStartAudioClipDraw, OnStartAudioClipListAdd, OnStartAudioClipListRemove); EditorGUI.indentLevel--; } DrawAudioFields(); if (InspectorUtility.Foldout(target, "Stop")) { EditorGUI.indentLevel++; m_ReorderableStopAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_Ability.StopAudioClipSet, null, m_ReorderableStopAudioClipsList, OnStopAudioClipDraw, OnStopAudioClipListAdd, OnStopAudioClipListRemove); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } var startEffectValue = InspectorUtility.GetFieldValue <string>(target, "m_StartEffectName"); var newStartEffectValue = InspectorUtility.DrawTypePopup(typeof(UltimateCharacterController.Character.Effects.Effect), startEffectValue, "Start Effect", true); if (startEffectValue != newStartEffectValue) { InspectorUtility.SetFieldValue(target, "m_StartEffectName", newStartEffectValue); InspectorUtility.SetDirty(parent); } if (!string.IsNullOrEmpty(newStartEffectValue)) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_StartEffectIndex"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "General")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_InspectorDescription"); GUI.enabled = !(target is MoveTowards); InspectorUtility.DrawField(target, "m_AllowPositionalInput"); InspectorUtility.DrawField(target, "m_AllowRotationalInput"); GUI.enabled = true; InspectorUtility.DrawField(target, "m_UseGravity"); InspectorUtility.DrawField(target, "m_UseRootMotionPosition"); InspectorUtility.DrawField(target, "m_UseRootMotionRotation"); InspectorUtility.DrawField(target, "m_DetectHorizontalCollisions"); InspectorUtility.DrawField(target, "m_DetectVerticalCollisions"); InspectorUtility.DrawField(target, "m_AnimatorMotion"); var itemAbilityMoveTowards = (target is MoveTowards) || (target is UltimateCharacterController.Character.Abilities.Items.ItemAbility); GUI.enabled = !itemAbilityMoveTowards; var inventory = (parent as Component).GetComponent <UltimateCharacterController.Inventory.InventoryBase>(); if (inventory != null && (parent as Component).GetComponent <UltimateCharacterController.Inventory.ItemSetManagerBase>() != null) { var slotCount = inventory.SlotCount; if (InspectorUtility.Foldout(target, "Allow Equipped Items")) { EditorGUI.indentLevel++; var mask = InspectorUtility.GetFieldValue <int>(target, "m_AllowEquippedSlotsMask"); var newMask = 0; for (int i = 0; i < slotCount; ++i) { var enabled = (mask & (1 << i)) == (1 << i); if (EditorGUILayout.Toggle("Slot " + i, enabled)) { newMask |= 1 << i; } } // If all of the slots are enabled then use -1. if (newMask == (1 << slotCount) - 1 || itemAbilityMoveTowards) { newMask = -1; } if (mask != newMask) { InspectorUtility.SetFieldValue(target, "m_AllowEquippedSlotsMask", newMask); } InspectorUtility.DrawField(target, "m_AllowItemDefinitions"); InspectorUtility.DrawField(target, "m_ImmediateUnequip"); InspectorUtility.DrawField(target, "m_ReequipSlots"); if (itemAbilityMoveTowards && InspectorUtility.GetFieldValue <bool>(target, "m_ReequipSlots")) { InspectorUtility.SetFieldValue(target, "m_ReequipSlots", false); GUI.changed = true; } EditorGUI.indentLevel--; } } GUI.enabled = true; EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "UI")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_AbilityMessageText"); InspectorUtility.DrawField(target, "m_AbilityMessageIcon"); 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--; } }