using UnityEngine; using UnityEditor; namespace Cinemachine.Editor { [CustomEditor(typeof(Cinemachine3rdPersonFollow))] [CanEditMultipleObjects] internal class Cinemachine3rdPersonFollowEditor : BaseEditor { [DrawGizmo(GizmoType.Active | GizmoType.Selected, typeof(Cinemachine3rdPersonFollow))] static void Draw3rdPersonGizmos(Cinemachine3rdPersonFollow target, GizmoType selectionType) { if (target.IsValid) { var isLive = CinemachineCore.Instance.IsLive(target.VirtualCamera); Color originalGizmoColour = Gizmos.color; Gizmos.color = isLive ? CinemachineSettings.CinemachineCoreSettings.ActiveGizmoColour : CinemachineSettings.CinemachineCoreSettings.InactiveGizmoColour; target.GetRigPositions(out Vector3 root, out Vector3 shoulder, out Vector3 hand); Gizmos.DrawLine(root, shoulder); Gizmos.DrawLine(shoulder, hand); Gizmos.DrawSphere(root, 0.02f); Gizmos.DrawSphere(shoulder, 0.02f); #if CINEMACHINE_PHYSICS Gizmos.DrawSphere(hand, target.CameraRadius); if (isLive) Gizmos.color = CinemachineSettings.CinemachineCoreSettings.BoundaryObjectGizmoColour; Gizmos.DrawSphere(target.VirtualCamera.State.RawPosition, target.CameraRadius); #endif Gizmos.color = originalGizmoColour; } } public override void OnInspectorGUI() { BeginInspector(); bool needWarning = false; for (int i = 0; !needWarning && i < targets.Length; ++i) needWarning = (targets[i] as Cinemachine3rdPersonFollow).FollowTarget == null; if (needWarning) EditorGUILayout.HelpBox( "3rd Person Follow requires a Follow Target. Change Body to Do Nothing if you don't want a Follow target.", MessageType.Warning); DrawRemainingPropertiesInInspector(); } } }