public override void OnBehaviourPlay(Playable playable, FrameData info) { if (mixer == null) { mixer = Misc.FindOutput <RemoteTalkMixerBehaviour>(playable); director = mixer.director; track = mixer.track; clip = mixer.FindClip(clipHash); } if (clip != null) { var rtc = (RemoteTalkClip)clip.asset; #if UNITY_EDITOR bool audipClipUpdated = rtc.UpdateCachedClip(true); if (audipClipUpdated) { Undo.RecordObject(track, "RemoteTalk"); clip.displayName = rtc.GetDisplayName(); rtc.UpdateCachedClip(); } #endif audioClip = rtc.GetAudioClip(); #if UNITY_EDITOR if (audipClipUpdated) { OnAudioClipUpdated(); } #endif } m_pending = true; }
public static bool ImportText(string path, TextImportOptions opt, TimelineAsset timeline, PlayableDirector director) { if (timeline == null || director == null) { return(false); } var talks = RemoteTalkScript.TextFileToTalks(path); if (talks == null) { return(false); } double time = opt.startTime; var oldArrange = arrangeClips; arrangeClips = ArrangeScope.CurrentTrack; if (opt.parCastTrack) { var tracks = new Dictionary <string, RemoteTalkTrack>(); foreach (var talk in talks) { RemoteTalkTrack track = null; if (!tracks.TryGetValue(talk.castName, out track)) { track = timeline.CreateTrack <RemoteTalkTrack>(null, "RemoteTalk"); track.director = director; track.name = talk.castName; tracks[talk.castName] = track; var audio = Misc.FindOrCreateGameObject(talk.castName + "_AudioSource"); track.audioSource = Misc.GetOrAddComponent <AudioSource>(audio); } var clip = track.AddClip(talk); clip.start = time; time += clip.duration + talk.wait + opt.interval; } } else { var track = timeline.CreateTrack <RemoteTalkTrack>(null, "RemoteTalk"); track.director = director; track.name = "RemoteTalkTrack"; var audio = Misc.FindOrCreateGameObject("RemoteTalkAudioSource"); track.audioSource = Misc.GetOrAddComponent <AudioSource>(audio); foreach (var talk in talks) { var clip = track.AddClip(talk); clip.start = time; time += clip.duration + talk.wait + opt.interval; } } arrangeClips = oldArrange; Misc.RefreshTimelineWindow(); return(false); }