RoboticArms/Library/PackageCache/com.unity.splines@d3e1e500c9a0/Editor/GUI/Editors/ElementDrawer.cs
2025-11-17 15:16:36 +07:00

37 lines
1.0 KiB
C#

using System.Collections.Generic;
using UnityEngine.Splines;
using UnityEngine.UIElements;
namespace UnityEditor.Splines
{
interface IElementDrawer
{
bool HasKnot(Spline spline, int index);
void PopulateTargets(IReadOnlyList<SplineInfo> splines);
void Update();
string GetLabelForTargets();
}
abstract class ElementDrawer<T> : VisualElement, IElementDrawer where T : ISelectableElement
{
public List<T> targets { get; } = new List<T>();
public T target => targets[0];
public virtual void Update() {}
public virtual string GetLabelForTargets() => string.Empty;
public bool HasKnot(Spline spline, int index)
{
foreach (var t in targets)
if (t.SplineInfo.Spline == spline && t.KnotIndex == index)
return true;
return false;
}
public void PopulateTargets(IReadOnlyList<SplineInfo> splines)
{
SplineSelection.GetElements(splines, targets);
}
}
}