Example #1
0
        public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
        {
            var playable = ScriptPlayable <LocalTimeBehaviour> .Create(graph, template);

            LocalTimeBehaviour clone = playable.GetBehaviour();

            return(playable);
        }
Example #2
0
        // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            LocalTimeComponet trackBinding = playerData as LocalTimeComponet;

            if (!trackBinding)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            var maxWeight = 0f;
            var time      = 0f;
            var duration  = 0f;

            for (int i = 0; i < inputCount; i++)
            {
                var weight = playable.GetInputWeight(i);
                if (Mathf.Approximately(weight, 0))
                {
                    continue;
                }

                ScriptPlayable <LocalTimeBehaviour> inputPlayable =
                    (ScriptPlayable <LocalTimeBehaviour>)playable.GetInput(i);
                LocalTimeBehaviour input = inputPlayable.GetBehaviour();

                // Use the above variables to process each frame of this playable.
                // NOTE: gam0022 単純なブレンドが難しい値は最もウェイトが高いクリップを採用
                if (weight > maxWeight)
                {
                    time      = (float)inputPlayable.GetTime();
                    duration  = (float)inputPlayable.GetDuration();
                    maxWeight = weight;
                }
            }

            trackBinding.ApplyTime(time, duration);
        }