示例#1
0
        internal override Playable OnCreatePlayableGraph(PlayableGraph graph, GameObject go, IntervalTree <RuntimeElement> tree)
        {
            AudioMixerPlayable audioMixerPlayable = AudioMixerPlayable.Create(graph, base.clips.Length, false);

            for (int i = 0; i < base.clips.Length; i++)
            {
                TimelineClip  timelineClip  = base.clips[i];
                PlayableAsset playableAsset = timelineClip.asset as PlayableAsset;
                if (!(playableAsset == null))
                {
                    float num = 0.1f;
                    AudioPlayableAsset audioPlayableAsset = timelineClip.asset as AudioPlayableAsset;
                    if (audioPlayableAsset != null)
                    {
                        num = audioPlayableAsset.bufferingTime;
                    }
                    Playable playable = playableAsset.CreatePlayable(graph, go);
                    if (playable.IsValid <Playable>())
                    {
                        tree.Add(new ScheduleRuntimeClip(timelineClip, playable, audioMixerPlayable, (double)num, 0.1));
                        graph.Connect <Playable, AudioMixerPlayable>(playable, 0, audioMixerPlayable, i);
                        playable.SetSpeed(timelineClip.timeScale);
                        playable.SetDuration(timelineClip.extrapolatedDuration);
                        audioMixerPlayable.SetInputWeight(playable, 1f);
                    }
                }
            }
            return(audioMixerPlayable);
        }
示例#2
0
 internal override void OnCreateClipFromAsset(Object asset, TimelineClip newClip)
 {
     if (asset is AudioClip)
     {
         AudioPlayableAsset audioPlayableAsset = ScriptableObject.CreateInstance <AudioPlayableAsset>();
         audioPlayableAsset.clip = (asset as AudioClip);
         newClip.asset           = audioPlayableAsset;
         newClip.duration        = audioPlayableAsset.duration;
         newClip.displayName     = (asset as AudioClip).name;
     }
 }
 protected override void DrawCustomClipBody(TrackDrawer.ClipDrawData drawData, Rect rect)
 {
     if (drawData.state.showAudioWaveform)
     {
         if (rect.get_width() > 0f)
         {
             TimelineClip clip      = drawData.clip;
             AudioClip    audioClip = clip.asset as AudioClip;
             if (audioClip == null)
             {
                 AudioPlayableAsset audioPlayableAsset = drawData.clip.asset as AudioPlayableAsset;
                 if (audioPlayableAsset != null)
                 {
                     audioClip = audioPlayableAsset.clip;
                 }
                 if (audioClip == null)
                 {
                     return;
                 }
             }
             Rect            rect2 = new Rect(Mathf.Ceil(rect.get_x()), Mathf.Ceil(rect.get_y()), Mathf.Ceil(rect.get_width()), Mathf.Ceil(rect.get_height()));
             WaveformPreview waveformPreview;
             if (!AudioTrackDrawer.s_PersistentPreviews.TryGetValue(drawData.clip, out waveformPreview) || audioClip != waveformPreview.presentedObject)
             {
                 WaveformPreview waveformPreview2 = WaveformPreviewFactory.Create((int)rect2.get_width(), audioClip);
                 AudioTrackDrawer.s_PersistentPreviews[drawData.clip] = waveformPreview2;
                 waveformPreview = waveformPreview2;
                 Color colorAudioWaveform = DirectorStyles.Instance.customSkin.colorAudioWaveform;
                 Color backgroundColor    = colorAudioWaveform;
                 backgroundColor.a = 0f;
                 waveformPreview.set_backgroundColor(backgroundColor);
                 waveformPreview.set_waveColor(colorAudioWaveform);
                 waveformPreview.SetChannelMode(0);
                 waveformPreview.add_updated(new Action(drawData.state.editorWindow.Repaint));
             }
             waveformPreview.set_looping(drawData.clip.SupportsLooping());
             waveformPreview.SetTimeInfo(drawData.localVisibleStartTime, drawData.localVisibleEndTime - drawData.localVisibleStartTime);
             waveformPreview.OptimizeForSize(rect2.get_size());
             if (Event.get_current().get_type() == 7)
             {
                 waveformPreview.ApplyModifications();
                 waveformPreview.Render(rect2);
             }
         }
     }
 }
示例#4
0
        public TimelineClip CreateClip(AudioClip clip)
        {
            TimelineClip result;

            if (clip == null)
            {
                result = null;
            }
            else
            {
                TimelineClip       timelineClip       = base.CreateDefaultClip();
                AudioPlayableAsset audioPlayableAsset = timelineClip.asset as AudioPlayableAsset;
                if (audioPlayableAsset != null)
                {
                    audioPlayableAsset.clip = clip;
                }
                timelineClip.duration    = (double)clip.length;
                timelineClip.displayName = clip.name;
                result = timelineClip;
            }
            return(result);
        }