Create a gist now

Instantly share code, notes, and snippets.

Embed
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Animations;
[RequireComponent(typeof(Animator))]
public class SimpleAnimation : MonoBehaviour {
PlayableGraph graph;
[SerializeField] string clipName = "RobotBoyRun";
void Awake()
{
graph = PlayableGraph.Create ();
}
void Start()
{
// アニメーションをResourcesから取得し
// AnimationClipPlayableを構築
var clip = Resources.Load<AnimationClip> (clipName);
var clipPlayable = AnimationClipPlayable.Create (graph, clip);
// outputを生成して、出力先を自身のAnimatorに設定
var output = AnimationPlayableOutput.Create (graph, "output", GetComponent<Animator>());
// playableをoutputに流し込む
output.SetSourcePlayable (clipPlayable);
graph.Play ();
}
void OnDestroy()
{
graph.Destroy ();
}
}
@tsubaki

This comment has been minimized.

Show comment
Hide comment
Owner

tsubaki commented Jul 29, 2017

animation 96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment