// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2023 Kybernetik //
using UnityEngine;
using UnityEngine.Playables;
namespace Animancer
{
/// Sets a as Animancer's .
///
/// This class allows Control Tracks to work properly when played in a .
///
/// Documentation: Exposed References
///
/// https://kybernetik.com.au/animancer/api/Animancer/ExposedPropertyTable
///
[AddComponentMenu(Strings.MenuPrefix + "Exposed Property Table")]
[HelpURL(Strings.DocsURLs.APIDocumentation + "/" + nameof(ExposedPropertyTable))]
[DefaultExecutionOrder(-10000)]// Initialize before anything else might need to use the table.
public class ExposedPropertyTable : MonoBehaviour
{
/************************************************************************************************************************/
[SerializeField] private AnimancerComponent _Animancer;
[SerializeField] private PlayableDirector _Director;
/************************************************************************************************************************/
/// Calls and if no was found it adds one.
protected virtual void Reset()
{
OnValidate();
if (_Director == null)
_Director = gameObject.AddComponent();
_Director.enabled = false;
_Director.playOnAwake = false;
}
/************************************************************************************************************************/
/// Tries to automatically find any missing references.
protected virtual void OnValidate()
{
gameObject.GetComponentInParentOrChildren(ref _Animancer);
gameObject.GetComponentInParentOrChildren(ref _Director);
}
/************************************************************************************************************************/
/// Sets the as Animancer's .
protected virtual void Awake()
{
_Animancer.Playable.Graph.SetResolver(_Director);
}
/************************************************************************************************************************/
}
}