Skip to content

Instantly share code, notes, and snippets.

@mnogue
Created October 11, 2022 15:51
Show Gist options
  • Save mnogue/444e8ae96152f12673207b1311329d02 to your computer and use it in GitHub Desktop.
Save mnogue/444e8ae96152f12673207b1311329d02 to your computer and use it in GitHub Desktop.
using System;
using UnityEngine;
using UnityEngine.Playables;
public class PlayAnimation : MonoBehaviour
{
public Animator animator;
public AnimationClip clip;
[NonSerialized] private PlayableGraph m_Graph;
private void OnEnable()
{
AnimationPlayableUtilities.PlayClip(this.animator, this.clip, out this.m_Graph);
}
private void OnDisable()
{
this.m_Graph.Destroy();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment