using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Internal;
using UnityEngine.Splines;
namespace UnityEditor.Splines
{
[ExcludeFromDocs]
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class CustomSplineDataHandle : Attribute
{
internal Type m_Type;
// Tells a PropertyDrawer class which run-time class or attribute it's a drawer for.
public CustomSplineDataHandle(Type type)
{
m_Type = type;
}
}
interface ISplineDataHandle
{
public SplineDataHandleAttribute attribute
{ get; }
void SetAttribute(SplineDataHandleAttribute attribute);
}
///
/// SplineDataHandle is a base class to override in order to enable custom handles for spline data.
/// The Drawer needs to inherit from this class and override the method corresponding to the correct splineData type.
/// Either one of the method or both can be overriden regarding the user needs.
///
///
/// The type parameter of the that this drawer targets.
///
public abstract class SplineDataHandle : ISplineDataHandle
{
internal int[] m_ControlIDs;
SplineDataHandleAttribute m_Attribute;
[ExcludeFromDocs]
public SplineDataHandleAttribute attribute => m_Attribute;
///
/// Array of reserved control IDs used for handles.
///
public int[] controlIDs => m_ControlIDs;
void ISplineDataHandle.SetAttribute(SplineDataHandleAttribute attribute)
{
m_Attribute = attribute;
}
///
/// Override this method to create custom handles for ,
/// this method is called before DrawKeyframe in the render loop.
///
/// The for which the method is drawing handles.
/// The target Spline associated to the SplineData for the drawing.
/// The spline localToWorld Matrix.
/// The color defined in the SplineData scene interface.
public virtual void DrawSplineData(SplineData splineData, Spline spline, Matrix4x4 localToWorld, Color color)
{}
///
/// Override this method to create custom handles for a in ,
/// 'position' and 'direction' are given in the Spline-space basis.
/// This method is called after DrawSplineData in the render loop.
///
/// A control ID from that represents this handle.
/// The position of the keyframe data in spline space.
/// The direction of the spline at the current keyframe.
/// The up vector orthogonal to the spline direction at the current keyframe regarding knot rotation.
/// The for which the method is drawing handles.
/// The index of the current keyframe to handle.
public virtual void DrawDataPoint(
int controlID,
Vector3 position,
Vector3 direction,
Vector3 upDirection,
SplineData splineData,
int dataPointIndex)
{}
}
}