{"id":16547,"date":"2017-08-14T17:24:51","date_gmt":"2017-08-14T08:24:51","guid":{"rendered":"http:\/\/labs.gree.jp\/blog\/?p=16547"},"modified":"2017-08-14T17:24:51","modified_gmt":"2017-08-14T08:24:51","slug":"%e3%81%af%e3%81%98%e3%82%81%e3%81%a6%e3%81%aescriptplayable","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2017\/08\/16547\/","title":{"rendered":"\u306f\u3058\u3081\u3066\u306eScriptPlayable"},"content":{"rendered":"<p>\u304a\u3072\u3055\u3057\u3067\u3059\u3002\u3061\u3087\u3073\u3048\u3067\u3059\u3002\u4eca\u56de\u3082Unity\u306e\u304a\u8a71\u3067PlayableGraph\u306eScriptPlayable\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u672c\u5f53\u306fUnity2017\u3067\u5165\u3063\u305fTimeline\u306e\u8a71\u3092\u66f8\u304d\u305f\u3044\u3093\u3067\u3059\u304c\u3001Timeline\u3092\u7d30\u304b\u304f\u8abf\u6574\u3059\u308b\u306b\u3042\u305f\u3063\u3066PlayableGraph, ScriptPlayable\u306f\u907f\u3051\u3066\u3082\u901a\u308c\u306a\u3044\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<p>ScriptPlayable\u306f\u6a5f\u80fd\u5358\u4f53\u3067\u307f\u308b\u3068\u3068\u3066\u3082\u5730\u5473\u306a\u306e\u3067\u3059\u304c\u3001\u308f\u304b\u3089\u306a\u3044\u307e\u307e\u4f7f\u3046\u3068\u7d50\u69cb\u5371\u3046\u3044\u3068\u3053\u308d\u3082\u3042\u308a\u3001\u30de\u30cb\u30e5\u30a2\u30eb\u3084\u30b5\u30f3\u30d7\u30eb\u3082\u5c11\u306a\u3081\u306a\u306e\u3067ScriptPlayable\u3092\u4f7f\u3063\u305fPlayableGraph\u3092\u5358\u4f53\u3067\u5b9f\u884c\u3067\u304d\u308b\u6240\u307e\u3067\u3092\u66f8\u3044\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002\u3081\u3063\u3061\u3083\u5730\u5473\u306a\u3093\u3067\u3059\u304cTimeline\u95a2\u9023\u306e\u81ea\u524d\u3067\u4f5c\u308b\u4eba\u306b\u306f\u3044\u308d\u3044\u308d\u53c2\u8003\u306b\u306a\u308b\u304b\u3068\u3002<\/p>\n<h2>ScriptPlayable<T0>\u3068\u306f<\/h2>\n<p>Unity2017.1\u306e<a href=\"https:\/\/docs.unity3d.com\/2017.1\/Documentation\/ScriptReference\/Playables.ScriptPlayable_1.html\">Script Reference<\/a>\u3092\u898b\u3066\u307f\u308b\u3068\u2026<\/p>\n<p>\u306f\u3044\u3002\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u3067\u3059\u306d\u3002dll\u306e\u4e2d\u8eab\u3092\u78ba\u8a8d\u3059\u308b\u3068ScriptPlayable\u306f<\/p>\n<pre class=\"lang:c# decode:true \" >public struct ScriptPlayable&lt;T&gt; : IPlayable, IEquatable&lt;ScriptPlayable&lt;T&gt;&gt; where T : class, IPlayableBehaviour, new()\n<\/pre>\n<p>\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3001ScriptPlayable\u306fPlayableBehaviour\u306e\u30ac\u30ef\u3001\u3068\u601d\u3063\u3066\u3082\u3089\u3048\u308c\u3070OK\u304b\u3068\u3002<br \/>\nPlayableAPI\u304cNative\u3067\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u95a2\u4fc2\u4e0a\u3053\u3046\u306a\u3063\u3066\u3044\u308b\u306e\u3060\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\nScriptPlayable\u3092\u4f7f\u3046\u3053\u3068\u3067\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u306e\u632f\u308b\u821e\u3044\u3092\u5b9a\u7fa9\u3067\u304d\u308b\u6a5f\u80fd\u3067Timeline\u306a\u3069\u3092\u6271\u3046\u5834\u5408\u306f\u304d\u3061\u3093\u3068\u628a\u63e1\u3057\u3066\u304a\u304f\u3079\u304d\u6a5f\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/docs.unity3d.com\/2017.1\/Documentation\/ScriptReference\/Playables.PlayableBehaviour.html\">PlayableBehaviour<\/a>\u306fIPlayableBehaviour, ICloneable\u3092\u5b9f\u88c5\u3059\u308b\u30af\u30e9\u30b9\u3067\u4e0b\u8a18\u30e1\u30bd\u30c3\u30c9\u304c\u671f\u5f85\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u25c6\u958b\u59cb\/\u7d42\u4e86<br \/>\nOnGraphStart\u3000\u30b0\u30e9\u30d5\u306e\u518d\u751f\u6642\u306b\u547c\u3070\u308c\u308b<br \/>\nOnGraphStop\u3000\u30b0\u30e9\u30d5\u306e\u505c\u6b62\u6642\u306b\u547c\u3070\u308c\u308b<\/p>\n<p>\u25c6\u751f\u6210\/\u7834\u68c4<br \/>\nOnPlayableCreate\u3000\u751f\u6210\u6642\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af<br \/>\nOnPlayableDestroy\u3000\u7834\u68c4\u6642\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af<\/p>\n<p>\u25c6\u5b9f\u884c\u6642<br \/>\nOnBehaviourPause\u3000Playable\u306e\u72b6\u614b\u304c\u30dd\u30fc\u30ba\u306b\u306a\u3063\u305f\u3089\u547c\u3070\u308c\u308b<br \/>\nOnBehaviourPlay\u3000Playable\u306e\u72b6\u614b\u304cPlay\u306b\u306a\u3063\u305f\u3089\u547c\u3070\u308c\u308b<\/p>\n<p>PrepareFrame\u3000ProcessFrame\u3088\u308a\u524d\u306bPlay\u72b6\u614b\u306eNode\u5168\u4f53\u3067\u518d\u5e30\u7684\u306b\u547c\u3070\u308c\u308b<br \/>\nProcessFrame\u3000PrepareFrame\u3088\u308a\u5f8c\u306bPlay\u72b6\u614b\u306eNode\u5168\u4f53\u3067\u518d\u5e30\u7684\u306b\u547c\u3070\u308c\u308b<\/p>\n<p>\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n<h2>ScriptPlayable\u306ePlayableGraph\u3092\u4f5c\u308b(1Playable\u306e\u307f)<\/h2>\n<p>\u7d30\u304b\u3044\u8a71\u306f\u304a\u3044\u3068\u3044\u3066\u3001\u3055\u304f\u3063\u3068ScriptPlayable\u3060\u3051\u306ePlayableGraph\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306fSampleBehaviour.cs\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:c# decode:true \" >\nusing UnityEngine;\nusing UnityEngine.Playables;\n\npublic class SampleBehaviour : PlayableBehaviour\n{\n    public string Name;\n\n    public override void OnGraphStart(Playable playable)\n    {\n        Debug.LogFormat(\"{0} start: {1}\",Time.frameCount, Name);\n    }\n\n    public override void OnBehaviourPause(Playable playable, FrameData info)\n    {\n        Debug.LogFormat(\"{0} pause: {1}\", Time.frameCount, Name);\n        var count = playable.GetInputCount();\n        \/\/ \u5b50\u306e\u72b6\u614b\u307e\u3067\u505c\u6b62\u3057\u3066\u304f\u308c\u306a\u3044\u306e\u3067\u597d\u307f\u306b\u3088\u3063\u3066\u6b62\u3081\u3066\u3082\u3088\u3044\u3068\u601d\u3046\n        for (var i = 0; i &lt; count; i++)\n        {\n            var input = playable.GetInput(i);\n            input.SetPlayState(PlayState.Paused);\n        }\n    }\n\n    public override void OnBehaviourPlay(Playable playable, FrameData info)\n    {\n        Debug.LogFormat(\"{0} play: {1}\", Time.frameCount, Name);\n    }\n\n    public override void OnGraphStop(Playable playable)\n    {\n        Debug.LogFormat(\"{0} stop: {1}\", Time.frameCount, Name);\n    }\n\n    public override void OnPlayableCreate(Playable playable)\n    {\n        Debug.LogFormat(\"{0} create: {1}\", Time.frameCount, Name);\n    }\n\n    public override void OnPlayableDestroy(Playable playable)\n    {\n        Debug.LogFormat(\"{0} destroy: {1}\", Time.frameCount, Name);\n    }\n\n    public override void PrepareFrame(Playable playable, FrameData info)\n    {\n        Debug.LogFormat(\"{0} prepare: {1}, {2}\", Time.frameCount, n, info.frameId);\n    }\n\n    public override void ProcessFrame(Playable playable, FrameData info, object playerData)\n    {\n        Debug.LogFormat(\"{0} process: {1}\", Time.frameCount, Name);\n    }\n}<\/pre>\n<p>\u3064\u304e\u306b\u30c6\u30b9\u30c8\u7528\u306e\u30b3\u30fc\u30c9\u3092\u4f5c\u308a\u307e\u3059\u3002\u307e\u305a\u306f\u4e00\u3064\u306ePlayable\u3060\u3051\u3092\u6301\u3064PlayableGraph\u3092\u4f5c\u308a\u307e\u3059<\/p>\n<p>SamplePlayable.cs<\/p>\n<pre class=\"lang:c# decode:true \" >using UnityEngine;\nusing UnityEngine.Playables;\n\npublic class SamplePlayable : MonoBehaviour\n{\n    private PlayableGraph graph;\n\n    \/\/ Use this for initialization\n    void Start()\n    {\n        graph = PlayableGraph.Create();\n\n        \/\/ \u7b2c\u4e8c\u5f15\u6570\u306fInput\u306e\u6570\u3002\u5f8c\u3067\u3082\u8a2d\u5b9a\u3067\u304d\u307e\u3059\n        \/\/ PlayableBehaviour\u306fScriptPlayable&lt;T&gt;.Create\u3092\u4f7f\u3063\u3066\u4f5c\u308b\u3053\u3068\u3092\u671f\u5f85\u3057\u3066\u3044\u308b\u306e\u3067\n        \/\/ \u76f4\u63a5\u4f5c\u3089\u306a\u3044\u3088\u3046\u306b\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002\n        var root = ScriptPlayable&lt;SampleBehaviour&gt;.Create(graph, 0);\n        \/\/ SampleBehaviour\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u306fGetBehaviour()\u3092\u4f7f\u3044\u307e\u3059\n        root.GetBehaviour().Name = \"root\";\n        \/\/ PlayableGraph\u306eOutput\u306b\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306bScriptPlayableOutput\u3092\u4f5c\u6210\u3057\n        \/\/ SetSourcePlayable\u3067\u4f5c\u6210\u3057\u305fPlayable\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\u6240\u8b02Root\u30ce\u30fc\u30c9\u307f\u305f\u3044\u306a\u3082\u3093\u3067\u3059\u3002\n        var output = ScriptPlayableOutput.Create(graph, \"output\");\n        output.SetSourcePlayable(root);\n        output.SetReferenceObject(gameObject);\n\n        \/\/ \u6e96\u5099\u304c\u3067\u304d\u305f\u306e\u3067Play\u3092\u30b3\u30fc\u30eb\u3057\u307e\u3059\u3002\n        \/\/ Manual\u4ee5\u5916\u306e\u5834\u5408\u306fUnity\u5074\u3067\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067Update\u4e2d\u306b\u547c\u3070\u306a\u304f\u3066\u3082OK\u3067\u3059\u3002\n        graph.Play();\n    }\n\n    private void OnDestroy()\n    {\n        if (graph.IsValid())\n        {\n            \/\/ graph\u306f\u5fc5\u305aDestroy\u3057\u3066\u958b\u653e\u3057\u3066\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308b\n            graph.Destroy();\n        }\n    }\n}<\/pre>\n<p>ScriptPlayableOutput\u306f2017\u306e\u73fe\u72b6\u3060\u3068ScriptPlayable\u3092\u6301\u3064Output\u3068\u3044\u3046\u76ee\u5370\u3067\u3059\u3002<\/p>\n<p>\u9069\u5f53\u306aGameObject\u306bSamplePlayable\u3092Add Component\u3057\u3066\u518d\u751f\u3057\u3066\u307f\u308b\u3068\u3053\u3093\u306a\u30ed\u30b0\u304c\u3067\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_1.png\" alt=\"\" width=\"330\" height=\"261\" class=\"alignnone size-full wp-image-16549\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_1.png 330w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_1-253x200.png 253w\" sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/a><br \/>\n1Playable\u3060\u3051\u3060\u3068\u3042\u3093\u307e\u308a\u304a\u3082\u3057\u308d\u304f\u306a\u3044\u3067\u3059\u304c\u3001\u3053\u3093\u306a\u3082\u3093\u3067\u3059\u3002<\/p>\n<h1>ScriptPlayable\u306ePlayableGraph\u3092\u4f5c\u308b(\u89aa\u5b50)<\/h1>\n<p>\u7d9a\u3044\u3066\u89aa\u5b50\u95a2\u4fc2\u3092\u6301\u3063\u305fPlayable\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3000\u89aa<br \/>\n\u5b50\u3000\u5b50<\/p>\n<p>\u3068\u3044\u3046\u304b\u3093\u3058\u306e\u30b0\u30e9\u30d5\u3067\u3059\u3002<\/p>\n<p>SamplePlayable2.cs<\/p>\n<pre class=\"lang:c# decode:true \" >using UnityEngine;\nusing UnityEngine.Playables;\n\npublic class SamplePlayable2 : MonoBehaviour\n{\n    private PlayableGraph graph;\n\n    \/\/ Use this for initialization\n    void Start()\n    {\n        graph = PlayableGraph.Create();\n\n        \/\/ \u7b2c\u4e8c\u5f15\u6570\u306fInput\u306e\u6570\u3002\u5f8c\u3067\u3082\u8a2d\u5b9a\u3067\u304d\u307e\u3059\n        \/\/ PlayableBehaviour\u306fScriptPlayable&lt;T&gt;.Create\u3092\u4f7f\u3063\u3066\u4f5c\u308b\u3053\u3068\u3092\u671f\u5f85\u3057\u3066\u3044\u308b\u306e\u3067\n        \/\/ \u76f4\u63a5\u4f5c\u3089\u306a\u3044\u3088\u3046\u306b\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002\n        var root = ScriptPlayable&lt;SampleBehaviour&gt;.Create(graph, 2); \/\/ Input\u306f2\u3068\u3044\u3046\u6307\u5b9a\u3092\u3057\u3066\u308b\u3053\u3068\u306b\u6ce8\u76ee\n        \/\/ SampleBehaviour\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u306fGetBehaviour()\u3092\u4f7f\u3044\u307e\u3059\n        root.GetBehaviour().Name = \"root\";\n\n\n        \/\/ PlayableGraph\u306eOutput\u306b\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306bScriptPlayableOutput\u3092\u4f5c\u6210\u3057\n        \/\/ SetSourcePlayable\u3067\u4f5c\u6210\u3057\u305fPlayable\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\u6240\u8b02Root\u30ce\u30fc\u30c9\u307f\u305f\u3044\u306a\u3082\u3093\u3067\u3059\u3002\n        var output = ScriptPlayableOutput.Create(graph, \"output\");\n        output.SetSourcePlayable(root);\n        output.SetReferenceObject(gameObject);\n\n\n        \/\/ \u5b50Playable\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4eca\u56de\u306e\u5b50\u306fLeaf\u30ce\u30fc\u30c9\u306b\u3042\u305f\u308b\u306e\u3067InputCount\u306f0\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\n        var child1 = ScriptPlayable&lt;SampleBehaviour&gt;.Create(graph, 0);\n        child1.GetBehaviour().Name = \"child1\";\n\n        var child2 = ScriptPlayable&lt;SampleBehaviour&gt;.Create(graph, 0);\n        child2.GetBehaviour().Name = \"child2\";\n\n        \/\/ Playable\u3092\u63a5\u7d9a\u3057\u307e\u3059\u3002\n        \/\/ \u5b50, \u5b50Output\u756a\u53f7 \u89aa, \u89aaInput\u756a\u53f7\u3068\u306a\u308b\u306e\u3067\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002\n        \/\/ Output\u3084Input\u306f\u5148\u306b\u3069\u308c\u304f\u3089\u3044\u8a2d\u5b9a\u3067\u304d\u308b\u304b\u6307\u5b9a\u3057\u306a\u3044\u3068\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u6ce8\u610f\n        graph.Connect(child1, 0, root, 0);\n        graph.Connect(child2, 0, root, 1);\n\n        \/\/ \u6e96\u5099\u304c\u3067\u304d\u305f\u306e\u3067Play\u3092\u30b3\u30fc\u30eb\u3057\u307e\u3059\u3002\n        \/\/ Manual\u4ee5\u5916\u306e\u5834\u5408\u306fUnity\u5074\u3067\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067Update\u4e2d\u306b\u547c\u3070\u306a\u304f\u3066\u3082OK\u3067\u3059\u3002\n        graph.Play();\n    }\n\n    private void OnDestroy()\n    {\n        if (graph.IsValid())\n        {\n            \/\/ graph\u306f\u5fc5\u305aDestroy\u3057\u3066\u958b\u653e\u3057\u3066\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308b\n            graph.Destroy();\n        }\n    }\n}<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3002\u3059\u3079\u3066\u306ePlayable\u304c\u5b9f\u884c\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_2.png\" alt=\"\" width=\"328\" height=\"535\" class=\"alignnone size-full wp-image-16550\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_2.png 328w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_2-123x200.png 123w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2017\/08\/playable_2-245x400.png 245w\" sizes=\"auto, (max-width: 328px) 100vw, 328px\" \/><\/a><\/p>\n<h1>SetTime, SetDuration\u3092\u3064\u304b\u3063\u3066\u307f\u308b<\/h1>\n<p>IPlayable\u3092\u5b9f\u88c5\u3057\u305f\u9805\u76ee\u306f<a href=\"https:\/\/docs.unity3d.com\/2017.1\/Documentation\/ScriptReference\/Playables.PlayableExtensions.html\">PlayableExtensions<\/a>\u306e\u62e1\u5f35\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>SamplePlayable3.cs<\/p>\n<pre class=\"lang:c# decode:true \" >using UnityEngine;\nusing UnityEngine.Playables;\n\npublic class SamplePlayable3 : MonoBehaviour\n{\n    private PlayableGraph graph;\n\n    \/\/ Use this for initialization\n    void Start()\n    {\n        graph = PlayableGraph.Create();\n\n        \/\/ \u7b2c\u4e8c\u5f15\u6570\u306fInput\u306e\u6570\u3002\u5f8c\u3067\u3082\u8a2d\u5b9a\u3067\u304d\u307e\u3059\n        \/\/ PlayableBehaviour\u306fScriptPlayable&lt;T&gt;.Create\u3092\u4f7f\u3063\u3066\u4f5c\u308b\u3053\u3068\u3092\u671f\u5f85\u3057\u3066\u3044\u308b\u306e\u3067\n        \/\/ \u76f4\u63a5\u4f5c\u3089\u306a\u3044\u3088\u3046\u306b\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002\n        var root = ScriptPlayable&lt;SampleBehaviour&gt;.Create(graph, 2); \/\/ Input\u306f2\u3068\u3044\u3046\u6307\u5b9a\u3092\u3057\u3066\u308b\u3053\u3068\u306b\u6ce8\u76ee\n        \/\/ SampleBehaviour\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u306fGetBehaviour()\u3092\u4f7f\u3044\u307e\u3059\n        root.GetBehaviour().Name = \"root\";\n        \/\/ PlayableExtensions\u3092\u4f7f\u3063\u3066Playable\u306e\u6642\u9593\u3068\u9577\u3055\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\n        root.SetTime(0);\n        root.SetDuration(1.0);\n\n        \/\/ PlayableGraph\u306eOutput\u306b\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306bScriptPlayableOutput\u3092\u4f5c\u6210\u3057\n        \/\/ SetSourcePlayable\u3067\u4f5c\u6210\u3057\u305fPlayable\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\u6240\u8b02Root\u30ce\u30fc\u30c9\u307f\u305f\u3044\u306a\u3082\u3093\u3067\u3059\u3002\n        var output = ScriptPlayableOutput.Create(graph, \"output\");\n        output.SetSourcePlayable(root);\n        output.SetReferenceObject(gameObject);\n\n\n        \/\/ \u5b50Playable\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4eca\u56de\u306e\u5b50\u306fLeaf\u30ce\u30fc\u30c9\u306b\u3042\u305f\u308b\u306e\u3067InputCount\u306f0\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\n        var child1 = ScriptPlayable&lt;SampleBehaviour&gt;.Create(graph, 0);\n        child1.GetBehaviour().Name = \"child1\";\n\n        var child2 = ScriptPlayable&lt;SampleBehaviour&gt;.Create(graph, 0);\n        child2.GetBehaviour().Name = \"child2\";\n\n        \/\/ PlayableExtensions\u3092\u4f7f\u3063\u3066Playable\u306e\u6642\u9593\u3068\u9577\u3055\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\n        \/\/ \u5b50\u306f\u8a66\u3057\u306bduration\u3092\u5909\u3048\u3066\u304a\u304d\u307e\u3057\u3087\u3045\u3002\n        child1.SetTime(0);\n        child1.SetDuration(0.5);\n        child2.SetTime(0);\n        child2.SetDuration(1.0);\n\n        \/\/ Playable\u3092\u63a5\u7d9a\u3057\u307e\u3059\u3002\n        \/\/ \u5b50, \u5b50Output\u756a\u53f7 \u89aa, \u89aaInput\u756a\u53f7\u3068\u306a\u308b\u306e\u3067\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002\n        \/\/ Output\u3084Input\u306f\u5148\u306b\u3069\u308c\u304f\u3089\u3044\u8a2d\u5b9a\u3067\u304d\u308b\u304b\u6307\u5b9a\u3057\u306a\u3044\u3068\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u6ce8\u610f\n        graph.Connect(child1, 0, root, 0);\n        graph.Connect(child2, 0, root, 1);\n\n        \/\/ \u6e96\u5099\u304c\u3067\u304d\u305f\u306e\u3067Play\u3092\u30b3\u30fc\u30eb\u3057\u307e\u3059\u3002\n        \/\/ Manual\u4ee5\u5916\u306e\u5834\u5408\u306fUnity\u5074\u3067\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067Update\u4e2d\u306b\u547c\u3070\u306a\u304f\u3066\u3082OK\u3067\u3059\u3002\n        graph.Play();\n    }\n\n    private void OnDestroy()\n    {\n        if (graph.IsValid())\n        {\n            \/\/ graph\u306f\u5fc5\u305aDestroy\u3057\u3066\u958b\u653e\u3057\u3066\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308b\n            graph.Destroy();\n        }\n    }\n}<\/pre>\n<p>\u304d\u3063\u3068\u3053\u308c\u3067\u5b9f\u884c\u3059\u308b\u3068\u3044\u3044\u611f\u3058\u306b\u6307\u5b9a\u6642\u9593\u3001\u9577\u3055\u3067\u3084\u3063\u3066\u304f\u308c\u308b\u3093\u3060\u308d\u3046\u306a\u3001\u3068\u601d\u3044\u307e\u3059\u304c\u305d\u3093\u306a\u3053\u3068\u306f\u306a\u304f\u3002<br \/>\nTime,Duration\u306f\u3042\u304f\u307e\u3067\u53c2\u8003\u60c5\u5831\u306a\u306e\u3067\u81ea\u524d\u3067\u5236\u5fa1\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>SampleBehaviour\u306ePrepareFrame\u3092\u6539\u5909\u3057\u307e\u3059\u3002\u3068\u308a\u3042\u3048\u305a\u52d5\u3051\u3070\u3044\u3044\u306e\u3067\u9069\u5f53\u3067\u3059\u3002<\/p>\n<pre class=\"lang:c# decode:true \" >    public override void PrepareFrame(Playable playable, FrameData info)\n    {\n        var time = playable.GetTime();\n        var count = playable.GetInputCount();\n        var stop_count = 0;\n\n        \/\/ \u3068\u308a\u3042\u3048\u305a\u52d5\u3051\u3070\u3044\u3044\u306e\u3067\u96d1\u306b\n        for (var i = 0; i &lt; count; i++)\n        {\n            var input = playable.GetInput(i);\n            var duration = input.GetDuration();\n            var begin = input.GetTime();\n\n            if (time &gt;= begin &amp;&amp; time &lt; begin + duration)\n            {\n                Debug.LogFormat(\"  {0} playing\", input);\n                input.SetPlayState(PlayState.Playing);\n            } else\n            {\n                Debug.LogFormat(\"  {0} paused\", input);\n                stop_count++;\n                input.SetPlayState(PlayState.Paused);\n            }\n        }\n\n        \/\/ count 0 (leaf node)\u3060\u3068\u305d\u306e\u307e\u307e\u3068\u307e\u3063\u3061\u3083\u3046\u306e\u3067\u5236\u9650\u3092\u5165\u308c\u3068\u304f\n        if (count &gt; 0 &amp;&amp; stop_count &gt;= count)\n        {\n            playable.SetPlayState(PlayState.Paused);\n        }\n    }\n}<\/pre>\n<p>\u3053\u308c\u3067\u89aa\u5b50\u3067Time\u3068Duration\u3092\u53c2\u7167\u3057\u305f\u3082\u306e\u304c\u671f\u5f85\u3057\u305f\u901a\u308a\u52d5\u304d\u307e\u3059\u3002<\/p>\n<h1>\u307e\u3068\u3081\u308b\u3068<\/h1>\n<p>PlayableBehaviour\u306f\u30de\u30a4\u30af\u30ed\u306a\u632f\u308b\u821e\u3044\u3092\u5b9a\u7fa9\u3057\u3066PlayableGraph\u3067\u89aa\u5b50\u95a2\u4fc2\u306a\u3069\u304c\u4f5c\u308c\u307e\u3059\u3002<\/p>\n<p>\u5b50Playable\u306eBlending\u3084Timeline\u306e\u3088\u3046\u306a\u7ba1\u7406\u306a\u3069\u3092\u884c\u3046\u5834\u5408\u306fMixerPlayable\u306a\u3069\u306e\u5b50\u3092\u30e9\u30c3\u30d7\u3059\u308bPlayable\u3092\u4f5c\u6210\u3057\u3066\u81ea\u524d\u3067\u30d6\u30ec\u30f3\u30c9\u306e\u30a6\u30a7\u30a4\u30c8\u306e\u8a08\u7b97\u3084\u3001Play\/Pause\u306e\u7ba1\u7406\u3092\u884c\u3063\u3066\u3044\u304f\u3053\u3068\u3067\u4efb\u610f\u306e\u6319\u52d5\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>PlayableGraph\u306e\u5229\u70b9\u3068\u3057\u3066\u306f\u3001\u304d\u3061\u3093\u3068PlayableAsset\u306eScriptableObject\u3092\u4f5c\u3063\u3066\u3055\u3048\u3044\u308c\u3070PlayableDirector\u306b\u6e21\u3057\u3066\u3042\u3052\u308b\u3060\u3051\u3067\u3069\u3093\u306a\u632f\u308b\u821e\u3044\u3082\u3055\u305b\u3089\u308c\u308b\u3068\u3044\u3046\u3068\u3053\u308d\u3067\u3059\u3002\u9006\u306b\u8a00\u3046\u3068\u7d30\u304b\u3044\u5236\u5fa1\u3068\u304b\u306f\u96e3\u3057\u304f\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30b1\u30fc\u30b9\u30d0\u30a4\u30b1\u30fc\u30b9\u3068\u3044\u3046\u3053\u3068\u3067\u3002<\/p>\n<p>\u307e\u305f\u5f8c\u65e5Timeline\u95a2\u9023\u306b\u3064\u3044\u3066\u3082\u6642\u9593\u304c\u3042\u308c\u3070\u66f8\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3061\u3087\u3063\u3068\u3060\u3051\u66f8\u3044\u3066\u304a\u304f\u3068Timeline\u306e\u4e2d\u8eab\u3068\u3057\u3066\u306f\u5927\u4f53Playable\u3067Track\u3001\u500b\u5225Mixer\u3001\u500b\u5225Playable\u304c\u305d\u308c\u305e\u308c\u81ea\u524d\u306e\u3084\u308b\u3079\u304d\u3053\u3068\u3084\u3063\u3066\u3044\u3044\u611f\u3058\u306b\u52d5\u304b\u3057\u3066\u3044\u308b\u3001\u3068\u8a8d\u8b58\u3057\u3066\u304a\u304f\u3068\u3088\u3044\u3067\u3059\u3002<br \/>\n(Mixer\u95a2\u4fc2\u306eBlending\u306f\u308f\u308a\u3068\u91cd\u8981\u306a\u306e\u3067\u5148\u306b\u6291\u3048\u3066\u304a\u304b\u306a\u3044\u3068\u5897\u3048\u305f\u5f8c\u306b\u76f4\u3059\u306e\u306f\u3068\u3066\u3082\u9762\u5012\u3067\u3059)<\/p>\n<p>\u7c21\u6613\u7684\u306bPlayableBehaviour\u3092\u8ffd\u52a0\u3059\u308b\u5834\u5408\u306fPlayableTrack\u306b\u7a81\u3063\u8fbc\u3080\u30b1\u30fc\u30b9\u304c\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u3060\u3068\u66f8\u304f\u30b3\u30fc\u30c9\u4e8b\u614b\u306f\u5c11\u306a\u3044\u3051\u3069\u500b\u5225\u30d0\u30a4\u30f3\u30c9\u3092\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u500b\u4eba\u7684\u306a\u304a\u52e7\u3081\u306fTrackAsset,MixerBehaviour, PlayableBeahviour, PlayableAsset4\u7a2e\u3092\u304d\u3061\u3093\u3068\u4f5c\u308a\u304d\u3063\u3066\u3084\u3063\u3066\u3044\u304f\u306e\u304c\u826f\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3089\u3078\u3093\u306f<a href=\"https:\/\/www.assetstore.unity3d.com\/jp\/#!\/content\/95266\">Default Playables<\/a> \u3092\u8aad\u3080\u306e\u304c\u4e00\u756a\u78ba\u5b9f\u306a\u306e\u3067\u53c2\u8003\u306b\u3059\u308b\u3068\u3088\u3044\u3067\u3059\u3002<\/p>\n<h1>\u88dc\u8db3<\/h1>\n<p>PlayableBehaviour\u3067Input\u3092\u53d6\u5f97\u3057\u305f\u969b\u306b\u3069\u3046\u3084\u3063\u3066PlayableBehaviour\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u304b\u3068\u3044\u3046\u3068<br \/>\n\u3053\u3093\u306a\u611f\u3058\u3067\u3001\u30ad\u30e3\u30b9\u30c8\u3057\u3066GetBeavhiour()\u3092\u30b3\u30fc\u30eb\u3059\u308c\u3070\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:c# decode:true \" >var v = (ScriptPlayable&lt;SimpleMotionBehaviour&gt;)playable.GetInput(0);\nDebug.Log(v.GetBehaviour().Name);<\/pre>\n<p>\u30c0\u30a4\u30ca\u30df\u30c3\u30af\u306b\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3092\u5909\u3048\u308b\u5834\u5408\u3084\u7d30\u304b\u3044\u64cd\u4f5c\u3092\u3059\u308b\u5834\u5408\u306f\u5fc5\u9808\u306b\u306a\u308b\u306e\u3067\u899a\u3048\u3066\u304a\u304f\u3068\u3088\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u304a\u3072\u3055\u3057\u3067\u3059\u3002\u3061\u3087\u3073\u3048\u3067\u3059\u3002\u4eca\u56de\u3082Unity\u306e\u304a\u8a71\u3067PlayableGraph\u306eScriptPlayable\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002 \u672c\u5f53\u306fUnity2017\u3067\u5165\u3063\u305fTimeline\u306e\u8a71\u3092\u66f8\u304d\u305f\u3044\u3093\u3067\u3059\u304c\u3001Tim [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[40],"class_list":["post-16547","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-unity"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/16547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=16547"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/16547\/revisions"}],"predecessor-version":[{"id":16561,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/16547\/revisions\/16561"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=16547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=16547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=16547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}