You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
1.1 KiB

using UnityEngine;
using UnityEngine.Animations.Rigging;
using UnityEngine.Playables;
namespace DocCodeExamples
{
/// <summary>
/// Custom evaluator that manually evaluates the PlayableGraph in LateUpdate.
/// </summary>
#region custom-playable-graph-evaluator
[RequireComponent(typeof(RigBuilder))]
public class CustomPlayableGraphEvaluator : MonoBehaviour
{
private RigBuilder m_RigBuilder;
private PlayableGraph m_PlayableGraph;
void OnEnable()
{
m_RigBuilder = GetComponent<RigBuilder>();
m_PlayableGraph = PlayableGraph.Create();
m_PlayableGraph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
m_RigBuilder.Build(m_PlayableGraph);
}
void OnDisable()
{
if (m_PlayableGraph.IsValid())
m_PlayableGraph.Destroy();
}
void LateUpdate()
{
m_RigBuilder.UpdateLayers();
m_PlayableGraph.Evaluate(Time.deltaTime);
m_RigBuilder.LateUpdateLayers();
}
}
#endregion
}