#if !CINEMACHINE_NO_CM2_SUPPORT using UnityEditor; using System.Collections.Generic; namespace Unity.Cinemachine.Editor { [System.Obsolete] [CustomEditor(typeof(CinemachineTransposer))] [CanEditMultipleObjects] class CinemachineTransposerEditor : BaseEditor { /// Get the property names to exclude in the inspector. /// Add the names to this list protected override void GetExcludedPropertiesInInspector(List excluded) { base.GetExcludedPropertiesInInspector(excluded); switch (Target.m_BindingMode) { default: case TargetTracking.BindingMode.LockToTarget: if (Target.m_AngularDampingMode == TargetTracking.AngularDampingMode.Euler) excluded.Add(FieldPath(x => x.m_AngularDamping)); else { excluded.Add(FieldPath(x => x.m_PitchDamping)); excluded.Add(FieldPath(x => x.m_YawDamping)); excluded.Add(FieldPath(x => x.m_RollDamping)); } break; case TargetTracking.BindingMode.LockToTargetNoRoll: excluded.Add(FieldPath(x => x.m_RollDamping)); excluded.Add(FieldPath(x => x.m_AngularDamping)); excluded.Add(FieldPath(x => x.m_AngularDampingMode)); break; case TargetTracking.BindingMode.LockToTargetWithWorldUp: excluded.Add(FieldPath(x => x.m_PitchDamping)); excluded.Add(FieldPath(x => x.m_RollDamping)); excluded.Add(FieldPath(x => x.m_AngularDamping)); excluded.Add(FieldPath(x => x.m_AngularDampingMode)); break; case TargetTracking.BindingMode.LockToTargetOnAssign: case TargetTracking.BindingMode.WorldSpace: excluded.Add(FieldPath(x => x.m_PitchDamping)); excluded.Add(FieldPath(x => x.m_YawDamping)); excluded.Add(FieldPath(x => x.m_RollDamping)); excluded.Add(FieldPath(x => x.m_AngularDamping)); excluded.Add(FieldPath(x => x.m_AngularDampingMode)); break; case TargetTracking.BindingMode.LazyFollow: excluded.Add(FieldPath(x => x.m_XDamping)); excluded.Add(FieldPath(x => x.m_PitchDamping)); excluded.Add(FieldPath(x => x.m_YawDamping)); excluded.Add(FieldPath(x => x.m_RollDamping)); excluded.Add(FieldPath(x => x.m_AngularDamping)); excluded.Add(FieldPath(x => x.m_AngularDampingMode)); break; } if (Target.HideOffsetInInspector) excluded.Add(FieldPath(x => x.m_FollowOffset)); } public override void OnInspectorGUI() { BeginInspector(); bool needWarning = false; for (int i = 0; !needWarning && i < targets.Length; ++i) needWarning = (targets[i] as CinemachineTransposer).FollowTarget == null; if (needWarning) EditorGUILayout.HelpBox( "Transposer requires a Tracking Target. Change Position Control to None if you don't want a Tracking target.", MessageType.Warning); DrawRemainingPropertiesInInspector(); } protected virtual void OnEnable() { CinemachineSceneToolUtility.RegisterTool(typeof(FollowOffsetTool)); } protected virtual void OnDisable() { CinemachineSceneToolUtility.UnregisterTool(typeof(FollowOffsetTool)); } void OnSceneGUI() { var transposer = Target; if (transposer == null || !transposer.IsValid) return; if (CinemachineSceneToolUtility.IsToolActive(typeof(FollowOffsetTool))) { var property = new SerializedObject(Target).FindProperty(() => Target.m_FollowOffset); var up = Target.VirtualCamera.State.ReferenceUp; CinemachineSceneToolHelpers.FollowOffsetTool( Target.VirtualCamera, property, Target.GetTargetCameraPosition(up), Target.FollowTargetPosition, Target.GetReferenceOrientation(up), () => { // Sanitize the offset property.vector3Value = Target.EffectiveOffset; property.serializedObject.ApplyModifiedProperties(); }); } } } } #endif