using UnityEditor;
using System.Collections.Generic;
using System;
using System.Reflection;
using Unity.Cinemachine.Editor;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
namespace Unity.Cinemachine
{
[CustomEditor(typeof(CinemachineFreeLookModifier))]
class CinemachineFreeLookModifierEditor : UnityEditor.Editor
{
CinemachineFreeLookModifier Target => target as CinemachineFreeLookModifier;
public override VisualElement CreateInspectorGUI()
{
var ux = new VisualElement();
var instructionsMsg = ux.AddChild(new HelpBox("This component is optional and can be removed if you don't need it. "
+ "The modifiers you add will override settings for the top and bottom portions "
+ "of the camera's vertical orbit.",
HelpBoxMessageType.Info));
var invalidSrcMsg = ux.AddChild(
new HelpBox("This component will be ignored because no modifiable targets are present.\n"
+ "You can remove this component.\nModifiable targets include: "
+ InspectorUtility.GetAssignableBehaviourNames(
typeof(CinemachineFreeLookModifier.IModifierValueSource)),
HelpBoxMessageType.Warning));
ux.Add(new PropertyField(serializedObject.FindProperty(nameof(Target.Easing))));
var controllersProperty = serializedObject.FindProperty(nameof(Target.Modifiers));
ux.Add(new Label(controllersProperty.displayName)
{ tooltip = controllersProperty.tooltip , style = { marginLeft = 3, marginTop = 6 }});
var list = ux.AddChild(new ListView()
{
reorderable = false,
showAddRemoveFooter = true,
showBorder = true,
showBoundCollectionSize = false,
showFoldoutHeader = false,
virtualizationMethod = CollectionVirtualizationMethod.DynamicHeight,
style = { marginLeft = 3 }
});
list.BindProperty(controllersProperty);
// Convert the add button to a popup selector
var button = list.Q