Dynamically obtain the Time attribute of Signal Emitter through the SignalTrack track in TimeLine

Through the SignalTrack track in TimeLine, the Time attribute of the Signal Emitter is dynamically obtained.
SignalTrack in TimeLine resource
In the process of using TimeLine to build scene animations, control particle effects, etc., it is often necessary to add signal tracks to respond to keyframe events to control project processes and step jumps, etc. ;

The Marker keyframe mark point will store the Time information at that position. If the TimeLine playback reaches the stored time, an event bound to the Marker will be triggered in advance; sometimes
insert image description here
we may need or take the Time value on the Maker to facilitate step skipping. Transfer and other related operations;

 public void Init() {
    
    

        TimeLine = GetComponent<PlayableDirector>();//获取自身TimeLine轨道控制组件

      
        foreach (var at in TimeLine.playableAsset.outputs)//获取TimeLine资源的全部轨道
        {
    
    
            //print(at.streamName);
            if (at.streamName == "Signal Track")//通过名称判定是否是信号轨道
            {
    
    

                var STK = at.sourceObject as SignalTrack;
                //print(STK.GetMarkerCount()); 获取该轨道上Marker的数量
                //print(STK.GetMarkers()); 获取该轨道上全部的Marker
                for (int i=0; i< STK.GetMarkerCount();i++) {
    
    
                    print(STK.GetMarker(i).time);//通过索引方法获取对应Marker的time




                }
            }
            
        }
    }

Guess you like

Origin blog.csdn.net/LCF_CSharp/article/details/127026977