예제 #1
0
        private void RunDefaultBehaviour()
        {
            switch (DefaultBehaviour)
            {
            case DefaultBehaviour.Through:
                // Do nothing.
                break;

            case DefaultBehaviour.Loop:
                JumpTo(
                    new TransitionablePredicate
                {
                    TargetType = TargetType.Clip,
                    Label      = Label,
                }
                    );
                break;

            case DefaultBehaviour.Wait:
                ActiveMixerBehaviour.Pause();
                PredicateList
                .Select(x => ResolvePredicateObservable(x).Select(__ => x))
                .Merge()
                .Take(1)
                .Subscribe(_ => ActiveMixerBehaviour.Resume());
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #2
0
        protected void JumpTo(ITransitionablePredicate predicate)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (predicate.TargetType)
            {
            case TargetType.None:
                break;

            case TargetType.Time:
                ActiveMixerBehaviour.SetTime(predicate.Time);
                break;

            case TargetType.Frame:
                ActiveMixerBehaviour.SetTime(predicate.Frame / ActiveMixerBehaviour.FrameRate);
                break;

            case TargetType.Clip:
                if (!ActiveMixerBehaviour.MarkerMap.ContainsKey(predicate.Label))
                {
                    throw new KeyNotFoundException($"Clip `{predicate.Label}' does not found in current ActiveTrack");
                }
                ActiveMixerBehaviour.SetTime(ActiveMixerBehaviour.MarkerMap[predicate.Label].StartTime);
                break;

            case TargetType.Next:
                ActiveMixerBehaviour.SetTime(ActiveMixerBehaviour.MarkerMap[Label].EndTime + 1 / ActiveMixerBehaviour.FrameRate);
                break;

            case TargetType.First:
                ActiveMixerBehaviour.SetTime(0);
                break;

            case TargetType.Last:
                ActiveMixerBehaviour.SetTime(ActiveMixerBehaviour.GetDuration());
                break;

            case TargetType.PlayableDirector:
                predicate.PlayableDirector.Resolve(ExposedPropertyTable).Play();
                break;

            case TargetType.Event:
                predicate.EventTrigger.Resolve(ExposedPropertyTable).OnTrigger.Invoke();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            // 全 ActiveBehaviour のウチ実行中のソレを強制的に End 扱いにする
            ActiveMixerBehaviour
            .ActiveTracks
            .SelectMany(x => x.ActiveMixerBehaviour.ActiveBehaviourList)
            .Where(x => x.IsProcessing())
            .ToList()
            .ForEach(x => x.End.Did());
        }
예제 #3
0
        // CreateTrackMixer は Hierarchy 上の PlayableDirector を選択しているときしか発火しないっぽい
        public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
        {
            var playable = ScriptPlayable <ActiveMixerBehaviour> .Create(graph, inputCount);

            var behaviour = playable.GetBehaviour();

            behaviour.FrameRate = timelineAsset.editorSettings.fps;
            foreach (var clip in GetClips())
            {
                var trackHolder = clip.asset as ITrackHolder;
                if (trackHolder != null)
                {
                    trackHolder.Track = this;
                }

                var label = ResolveLabel(clip);
                clip.displayName = label;

                if (behaviour.MarkerMap.ContainsKey(label))
                {
                    Debug.LogWarning($"Marker name `{label}' already contains in `{name}' track. Please check all clips.");
                    continue;
                }

                behaviour.MarkerMap[label] = new Marker
                {
                    StartTime  = clip.start,
                    EndTime    = clip.end,
                    Processing = false,
                };
            }

            MarkerMap = behaviour.MarkerMap;

            ActiveMixerBehaviour = behaviour;

            return(playable);
        }
예제 #4
0
 protected bool IsProcessing()
 {
     return(ActiveMixerBehaviour.IsProcessing(Label));
 }
예제 #5
0
 protected bool IsContainTime()
 {
     return(ActiveMixerBehaviour.IsContainTime(Label));
 }
예제 #6
0
 protected void SetProcessing(bool processing)
 {
     ActiveMixerBehaviour.SetProcessing(Label, processing);
 }