Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

73 行
3.3 KiB

using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace Cinemachine.Editor
{
[CustomEditor(typeof(CinemachineTransposer))]
internal sealed class CinemachineTransposerEditor : BaseEditor<CinemachineTransposer>
{
protected override List<string> GetExcludedPropertiesInInspector()
{
List<string> excluded = base.GetExcludedPropertiesInInspector();
switch (Target.m_BindingMode)
{
default:
case CinemachineTransposer.BindingMode.LockToTarget:
break;
case CinemachineTransposer.BindingMode.LockToTargetNoRoll:
excluded.Add(FieldPath(x => x.m_RollDamping));
break;
case CinemachineTransposer.BindingMode.LockToTargetWithWorldUp:
excluded.Add(FieldPath(x => x.m_PitchDamping));
excluded.Add(FieldPath(x => x.m_RollDamping));
break;
case CinemachineTransposer.BindingMode.LockToTargetOnAssign:
case CinemachineTransposer.BindingMode.WorldSpace:
excluded.Add(FieldPath(x => x.m_PitchDamping));
excluded.Add(FieldPath(x => x.m_YawDamping));
excluded.Add(FieldPath(x => x.m_RollDamping));
break;
case CinemachineTransposer.BindingMode.SimpleFollowWithWorldUp:
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));
break;
}
return excluded;
}
public override void OnInspectorGUI()
{
BeginInspector();
if (Target.FollowTarget == null)
EditorGUILayout.HelpBox(
"Transposer requires a Follow Target. Change Body to Do Nothing if you don't want a Follow target.",
MessageType.Warning);
DrawRemainingPropertiesInInspector();
}
[DrawGizmo(GizmoType.Active | GizmoType.Selected, typeof(CinemachineTransposer))]
static void DrawTransposerGizmos(CinemachineTransposer target, GizmoType selectionType)
{
if (target.IsValid)
{
Color originalGizmoColour = Gizmos.color;
Gizmos.color = CinemachineCore.Instance.IsLive(target.VirtualCamera)
? CinemachineSettings.CinemachineCoreSettings.ActiveGizmoColour
: CinemachineSettings.CinemachineCoreSettings.InactiveGizmoColour;
Vector3 up = Vector3.up;
CinemachineBrain brain = CinemachineCore.Instance.FindPotentialTargetBrain(target.VirtualCamera);
if (brain != null)
up = brain.DefaultWorldUp;
Vector3 targetPos = target.FollowTarget.position;
Vector3 desiredPos = target.GeTargetCameraPosition(up);
Gizmos.DrawLine(targetPos, desiredPos);
Gizmos.DrawWireSphere(desiredPos, HandleUtility.GetHandleSize(desiredPos) / 20);
Gizmos.color = originalGizmoColour;
}
}
}
}