void setClipOffset(GameObject animTimeline, Vector3 anim_location, Quaternion anim_rotation)
    {
        // SET ATTRIBUTES OF TARGET TIMELINE, a child of some gameobject is the convention

        PlayableDirector       anim_director     = animTimeline.GetComponent <PlayableDirector>();
        List <PlayableBinding> playable_list     = anim_director.playableAsset.outputs.ToList();
        TrackAsset             target_anim_track = playable_list[0].sourceObject as AnimationTrack;

        foreach (TimelineClip track_clip in target_anim_track.GetClips())
        {
            AnimationPlayableAsset target_anim_clip = track_clip.asset as AnimationPlayableAsset;
            target_anim_clip.position = anim_location;
            target_anim_clip.rotation = anim_rotation;
        }

        // this is the animation track, always; here, we are setting an offset
        //TrackAsset target_anim_track = playable_list[0].sourceObject as AnimationTrack;
        //List<TimelineClip> track_clips = target_anim_track.GetClips().ToList();
        //AnimationPlayableAsset target_anim_clip = track_clips[0].asset as AnimationPlayableAsset;
        //target_anim_clip.position = start_pos;

        // this is the lerp track, always; here, we set destination
        //TrackAsset target_lerp_track = playable_list[1].sourceObject as PlayableTrack;
        //List<TimelineClip> lerp_clips = target_lerp_track.GetClips().ToList();
    }
Exemplo n.º 2
0
        public static TimelineClip GetFirstClip(TrackAsset t)
        {
            IEnumerable <TimelineClip> cS = t.GetClips();
            var timelineClips             = cS.ToList();

            return(timelineClips.Count == 0 ? null : timelineClips.First());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查找指定名称的TimelineClip
        /// </summary>
        /// <param name="_trackAsset">TrackAsset</param>
        /// <param name="_timelineClipDisplayName">TimelineClip名称</param>
        /// <returns>TimelineClip</returns>
        public static TimelineClip FindTimelineClip(this TrackAsset _trackAsset, string _timelineClipDisplayName)
        {
            TimelineClip timelineClip = null;

            if (_trackAsset != null)
            {
                IEnumerator outClips = _trackAsset.GetClips().GetEnumerator();
                while (outClips.MoveNext())
                {
                    TimelineClip tc = (TimelineClip)outClips.Current;
                    if (tc.displayName.Equals(_timelineClipDisplayName))
                    {
                        timelineClip = tc;
                        break;
                    }
                }
            }
#if UNITY_EDITOR
            if (timelineClip == null)
            {
                Debug.LogErrorFormat("Can't find TimelineClip  for【{0}】.", _timelineClipDisplayName);
            }
#endif
            return(timelineClip);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 查找指定PlayableAsset的TimelineClip
        /// </summary>
        /// <param name="_trackAsset">TrackAsset</param>
        /// <param name="_playableAsset">PlayableAsset</param>
        /// <returns></returns>
        public static TimelineClip FindTimelineClip(this TrackAsset _trackAsset, PlayableAsset _playableAsset)
        {
            TimelineClip mTimelineClip = null;

            if (_playableAsset != null)
            {
                IEnumerator outClips = _trackAsset.GetClips().GetEnumerator();
                while (outClips.MoveNext())
                {
                    TimelineClip clip = (TimelineClip)outClips.Current;
                    if (clip.asset.Equals(_playableAsset))
                    {
                        mTimelineClip = clip;
                        break;
                    }
                }
            }
#if UNITY_EDITOR
            if (mTimelineClip == null)
            {
                Debug.LogErrorFormat("Can't find TimelineClip by【{0}】in the【{1}]】.", _trackAsset, _playableAsset);
            }
#endif
            return(mTimelineClip);
        }
 public void Bind(IEnumerable <IDynamicBind <CinemachineVirtualCamera> > RefData, PlayableDirector director)
 {
     foreach (var item in RefData)
     {
         TrackAsset   track    = item.Timeline.GetOutputTracks().FirstOrDefault(x => x.name == item.TrackName);
         TimelineClip clip     = track.GetClips().FirstOrDefault(x => x.displayName == item.ClipName);
         var          VcamClip = clip.asset as CinemachineShot;
         director.SetReferenceValue(VcamClip.VirtualCamera.exposedName, _BindTable[item.ListKey]);
     }
 }
Exemplo n.º 6
0
            public TrackData(TrackAsset track)
            {
                Track = track;

                var clips = Track.GetClips();

                // 名前で辞書を作る
                ClipDict = clips.ToDictionary(clip => clip.displayName);
                Clips    = clips.ToList();
            }
    // Start is called before the first frame update
    void Start()
    {
        LockViewScript = PlayerCamera.GetComponent <LockView>();
        BathroomAttendantSaysHeNeedsForint = FMODUnity.RuntimeManager.CreateInstance("event:/Dialogue/BathroomAttendant/forintNeededToEnter");
        BathroomAttendantSaysThankYou      = FMODUnity.RuntimeManager.CreateInstance("event:/Dialogue/BathroomAttendant/bathroomAttendantSaysThankYou");
        GottaGoGottaGoGottaGoGoGo          = FMODUnity.RuntimeManager.CreateInstance("event:/Bathroom Cutscene/gottaGoGottaGoGottaGoGoGo");
        RepeatForint = FMODUnity.RuntimeManager.CreateInstance("event:/Dialogue/BathroomAttendant/RepeatForint");

        bathroomCutsceneTimelineTrack = bathroomCutsceneTimeline.GetOutputTrack(0);
        bathroomCutsceneTimelineClip  = bathroomCutsceneTimelineTrack.GetClips();
    }
Exemplo n.º 8
0
 public void SetDetails(TrackAsset track, string uid,PlayableDirector director)
 {
     this._uid = uid;
     this._Rootwidth = this._TrackRoot.sizeDelta.x;
     this._track = track;
     this._NameTxt.text = this._track.name;
     foreach (TimelineClip clip in track.GetClips())
     {
         this.CreateOneClip(clip, director);
     }
 }
Exemplo n.º 9
0
 public static void AddTimelineEvent(TrackAsset track)
 {
     foreach (var clip in track.GetClips())
     {
         if (clip != null)
         {
             var clipasset = clip.asset as TimelineEvent;
             AddEvent(clipasset.msg, clipasset.lParam, clipasset.fParam, clipasset.sParam, clip.start, TimelineEvent2.ENTER_MSG);
             //AddEvent(clipasset.name, clipasset.lParam, clipasset.fParam, clipasset.sParam, clip.end, TimelineEvent2.LEAVE_MSG);
         }
     }
 }
Exemplo n.º 10
0
        public static void ClearTrack(TimelineAsset timelineAsset, TrackAsset trackAsset)
        {
            IEnumerable <TimelineClip> cS = trackAsset.GetClips();

                        #if UNITY_EDITOR
            Undo.RecordObject(timelineAsset, "Set Clean TimelineClip");
                        #endif
            foreach (TimelineClip c in cS)
            {
                timelineAsset.DeleteClip(c);
            }
        }
        public IEnumerator DetectActiveClip()
        {
            PlayableDirector director = CreateDirectorWithTimelineAsset(TIMELINE_ASSET_PATH, out TimelineAsset timelineAsset);

            TimelineEditorUtility.SelectDirectorInTimelineWindow(director); //trigger the TimelineWindow's update etc.
            yield return(YieldEditorUtility.WaitForFramesAndIncrementUndo(1));

            TrackAsset          track     = timelineAsset.CreateTrack <DummyTimelineTrack>(null, "FooTrack");
            List <TimelineClip> clips     = new List <TimelineClip>();
            const int           NUM_CLIPS = 3;

            double nextClipStart = 0;

            for (int i = 0; i < NUM_CLIPS; ++i)
            {
                TimelineClip curClip = TimelineEditorReflection.CreateClipOnTrack(typeof(DummyTimelinePlayableAsset), track, 0);
                curClip.asset.name = $"Clip Asset {i}";
                curClip.start      = nextClipStart;
                nextClipStart     += curClip.duration;
                clips.Add(curClip);

                yield return(YieldEditorUtility.WaitForFramesAndIncrementUndo(1));
            }

            //Check that all clips have been created successfully
            List <TimelineClip>    trackClips        = new List <TimelineClip>(track.GetClips());
            HashSet <TimelineClip> trackClipsToCheck = new HashSet <TimelineClip>(trackClips);

            for (int i = 0; i < NUM_CLIPS; ++i)
            {
                Assert.IsTrue(trackClipsToCheck.Contains(clips[i]));
                trackClipsToCheck.Remove(clips[i]);
            }
            NUnit.Framework.Assert.Zero(trackClipsToCheck.Count);
            yield return(YieldEditorUtility.WaitForFramesAndIncrementUndo(3));

            //Ensure the active clip can be detected
            for (int i = 0; i < NUM_CLIPS; ++i)
            {
                TimelineClip curClip = clips[i];
                double       time    = curClip.start + curClip.duration * 0.5f;
                TimelineUtility.GetActiveTimelineClipInto(trackClips, time, out TimelineClip detectedClip, out TimelineAsset _);
                Assert.AreEqual(curClip, detectedClip);
            }

            yield return(YieldEditorUtility.WaitForFramesAndIncrementUndo(1));

            TimelineEditorUtility.DestroyAssets(timelineAsset); //Cleanup
        }
Exemplo n.º 12
0
                protected virtual void OnDrawSubTrack(Rect rect, int index, bool selected, bool focused)
                {
                    float      columnWidth = rect.width / 3f;
                    TrackAsset track       = _channelTracks.list[index] as TrackAsset;

                    if (track != null)
                    {
                        rect.width = columnWidth;
                        GUI.Label(rect, track.name, EditorStyles.label);
                        rect.x += columnWidth;
                        GUI.Label(rect, track.duration.ToString(), EditorStyles.label);
                        rect.x += columnWidth;
                        GUI.Label(rect, ArrayUtils.GetCount(track.GetClips()).ToString(), EditorStyles.label);
                    }
                }
Exemplo n.º 13
0
        /// <summary>
        /// クリップを取得
        /// </summary>
        T GetClip <T>(string trackName, string clipName) where T : PlayableAsset
        {
            TrackAsset track = GetTrackList().FirstOrDefault(x => x.name == trackName);

            if (track != null)
            {
                var          clips = track.GetClips();
                TimelineClip clip  = clips.FirstOrDefault(x => x.displayName == clipName);
                if (clip != null && clip.asset != null)
                {
                    return(clip.asset as T);
                }
            }

            return(null);
        }
        // Find the gap at the given time
        //  return true if there is a gap, false if there is an intersection
        // endGap will be Infinity if the gap has no end
        internal static bool GetGapAtTime(this TrackAsset track, double time, out double startGap, out double endGap)
        {
            startGap = 0;
            endGap   = Double.PositiveInfinity;

            if (track == null || !track.GetClips().Any())
            {
                return(false);
            }

            var discreteTime = new DiscreteTime(time);

            track.SortClips();
            var sortedByStartTime = track.clips;

            for (int i = 0; i < sortedByStartTime.Length; i++)
            {
                var clip = sortedByStartTime[i];

                // intersection
                if (discreteTime >= new DiscreteTime(clip.start) && discreteTime < new DiscreteTime(clip.end))
                {
                    endGap   = time;
                    startGap = time;
                    return(false);
                }

                if (clip.end < time)
                {
                    startGap = clip.end;
                }
                if (clip.start > time)
                {
                    endGap = clip.start;
                    break;
                }
            }

            if (endGap - startGap < TimelineClip.kMinDuration)
            {
                startGap = time;
                endGap   = time;
                return(false);
            }

            return(true);
        }
Exemplo n.º 15
0
            //Finds the TimelineClip corresponding to a playable asset in a parent track
            public static TimelineClip GetClip(TrackAsset track, IPlayableAsset Clip)
            {
                if (track != null)
                {
                    IEnumerable <TimelineClip> clips = track.GetClips();

                    foreach (TimelineClip clip in clips)
                    {
                        if (clip.asset == (Object)Clip)
                        {
                            return(clip);
                        }
                    }
                }

                return(null);
            }
        // 이펙트 사운드 추가
        private void AddEffectSound(TrackAsset track)
        {
            if (track.GetType() != typeof(PlaySoundTack))
            {
                return;
            }

            var clips = track.GetClips();

            if (clips == null)
            {
                return;
            }

            foreach (var clip in clips)
            {
                var clipAsset = clip.asset as PlaySoundClip;
                if (clipAsset == null || clipAsset.template?.SoundDatas == null)
                {
                    continue;
                }

                var soundDataList = clipAsset.template.SoundDatas;
                foreach (var soundData in soundDataList)
                {
                    if (soundData == null || soundData.SoundName.IsNullOrEmpty())
                    {
                        continue;
                    }
                    var data = GameDataManager.Instance.GetData <MsgSound>(soundData.SoundName);
                    if (data == null || data.file_name.IsNullOrEmpty())
                    {
                        continue;
                    }

                    var fileName = data.file_name;
                    if (_effectSoundNames.Contains(fileName))
                    {
                        continue;
                    }

                    _effectSoundNames.Add(data.file_name);
                }
            }
        }
Exemplo n.º 17
0
        private float DrawTrack(float nextStartY, GUIStyle trackLineStyle, TrackAsset track)
        {
            float kHeaderLineWidth = 3.0f;

            Rect tRect = new Rect(kLeftMerginOfHeader + m_fIndent, nextStartY, kHederWidthGroupTrack - m_fIndent - 1.0f, kHeaderTrackHeight);

            GUI.Box(tRect, GUIContent.none, m_trackHeaderStyle);
            tRect.width = kHeaderLineWidth;
            GUI.Box(tRect, GUIContent.none, trackLineStyle);


            Rect tRightBodyRect = new Rect(kHeaderWidth + kLineWidth, nextStartY, Screen.width - (kHeaderWidth + kLineWidth), kHeaderTrackHeight);

            GUI.Box(tRightBodyRect, GUIContent.none, m_trackBGStyle);

            foreach (var clip in track.GetClips())
            {
                DrawClip(nextStartY, trackLineStyle, clip);
            }
            nextStartY += kHeaderTrackHeight + 2;
            return(nextStartY);
        }
Exemplo n.º 18
0
    // Start is called before the first frame update
    void Start()
    {
        playable    = gameObject.GetComponent <PlayableDirector>();
        light       = gameObject.GetComponent <Light>();
        bindingDict = new Dictionary <string, PlayableBinding>();
        foreach (var bind in playable.playableAsset.outputs)
        {
            bindingDict.Add(bind.streamName, bind);
        }

        // 动态绑定轨道中的节点 SetGenericBinding
//        playable.SetGenericBinding(bindingDict["LightTrack1"].sourceObject, light);
        playable.SetGenericBinding(bindingDict["Animation1"].sourceObject, sphere);


        // 动态绑定轨道中clip的节点 SetReferenceValue
        foreach (var track in ((TimelineAsset)playable.playableAsset).GetOutputTracks())
        {
//            track.muted = false;
            foreach (var clip in track.GetClips())
            {
                LightControlAsset asset = clip.asset as LightControlAsset;
                if (asset != null)
                {
                    playable.SetReferenceValue(asset.light.exposedName, light);
                }
                ControlPlayableAsset asset2 = clip.asset as ControlPlayableAsset;
                if (asset2 != null)
                {
                    playable.SetReferenceValue(asset2.sourceGameObject.exposedName, sphere);
                }
            }
        }
        playable.SetGenericBinding(bindingDict["ActivationTrack"].sourceObject, null);
//        playable.RebuildGraph();
        // 获取track信息
        TimelineAsset timelineAsset = (TimelineAsset)playable.playableAsset;
//        timelineAsset.DeleteTrack()
//        timelineAsset.A
        var count = timelineAsset.outputTrackCount;

        for (int i = 1; i < count; i++)
        {
            TrackAsset asset = timelineAsset.GetOutputTrack(i);
            var        clips = asset.GetClips();
            foreach (TimelineClip clip in clips)
            {
                var playableAsset = (PlayableAsset)clip.asset;
                var lightAsset    = playableAsset as LightControlAsset;
                if (lightAsset != null)
                {
//                    lightAsset.behaviour.OnGraphStop();
                }
//                var behaviout = playableAsset.behaviour;
            }
        }

//        var graphCount = playable.playableGraph.GetOutputCount();
//        for (int i = 0; i < graphCount; i++)
//        {
//
////            var playable1 = playable.playableGraph.GetRootPlayable(i);
//            PlayableOutput output = playable.playableGraph.GetOutput(i);
//            var p1 = output.GetSourcePlayable();
////            p1.GetInputCount();
//            Playable i1 = p1.GetInput(1);
////            playable.playableAsset
////            i1.SetInputWeight(0);
//
////            output.SetWeight();
//            var graph = playable.playableGraph;
////            graph
//            var playable2 = output.GetSourcePlayable();
//        }
        playable.Play();
    }