Created
July 30, 2017 04:08
-
-
Save tsubaki/91d4cfebd199fdbc8700bbae1c2edf4e to your computer and use it in GitHub Desktop.
PlayableOutputのターゲットを切り替えるサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Playables; | |
using UnityEngine.Animations; | |
public class ChangeTargetAnimator : MonoBehaviour | |
{ | |
PlayableGraph graph; | |
AnimationPlayableOutput output; | |
AnimationClipPlayable clipPlayable; | |
[SerializeField] Animator[] animators; | |
[SerializeField] AnimationClip clip; | |
void Awake() | |
{ | |
graph = PlayableGraph.Create (); | |
} | |
void Start() | |
{ | |
clipPlayable = AnimationClipPlayable.Create (graph, clip); | |
output = AnimationPlayableOutput.Create (graph, "animation", null); | |
output.SetSourcePlayable (clipPlayable); | |
graph.Play (); | |
} | |
void OnGUI() | |
{ | |
foreach( var anim in animators){ | |
if (GUILayout.Button (anim.name)) { | |
output.SetTarget (anim); | |
clipPlayable.SetTime (0); | |
} | |
} | |
} | |
void OnDestroy() | |
{ | |
graph.Destroy (); | |
} | |
} |
Author
tsubaki
commented
Jul 30, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment