using System.Collections.Generic; using Mono.UI.Core; using UnityEngine; using UnityEngine.Playables; using UnityEngine.SceneManagement; using UnityEngine.Timeline; using UnityEngine.UI; namespace Mono { [UIBinding(prefab = "TipPanel")] public class TipPanel : UIPanel { public Text Text_00; public Typewriter Text_01; public override void GetUIData() { Text_00 = UIData.Get("Text_00"); Text_01 = UIData.Get("Text_01"); } public override void Show() { base.Show(); index = 0; Text_01.StringContent = "龙泉剑\n在白帝城偶遇诗仙李白获赠的随身佩剑"; Text_01.SetContent(); } private int index = 0; /// /// 所有的轨道组 /// public List trackGroups = new List(); public void ResetTrackAsset(PlayableDirector pd) { trackGroups.Clear(); TimelineAsset ta = (TimelineAsset)pd.playableAsset; for (int i = 0; i < ta.rootTrackCount; i++) { TrackAsset trackAsset = ta.GetRootTrack(i); trackAsset.muted = true; trackGroups.Add(trackAsset); } } private void MuteAll() { foreach (TrackAsset trackGroup in trackGroups) { // trackGroup. trackGroup.muted = true; } } public void DBJNext() { PlayableDirector playableDirector = GameObject.Find("timeline").gameObject.GetComponent(); ResetTrackAsset(playableDirector); MuteAll(); foreach (var trackGroup in trackGroups) { switch (index) { case 0: if (trackGroup.name == "1") { trackGroup.muted = false; } break; case 1: if (trackGroup.name == "2") { trackGroup.muted = false; } break; } } // foreach (var playableAssetOutput in playableDirector.playableAsset.outputs) // { // // TrackAsset asset = playableAssetOutput.sourceObject as TrackAsset; // asset.muted = true; // } // // // foreach (var playableAssetOutput in playableDirector.playableAsset.outputs) // { // TrackAsset asset = playableAssetOutput.sourceObject as TrackAsset; // // // switch (index) // { // case 0: // // if (asset.GetGroup().name == "1") // { // asset.muted = false; // } // // break; // // case 1: // // if (asset.GetGroup().name == "2") // { // asset.muted = false; // } // // // break; // } // } playableDirector.time = 0; playableDirector.Play(); index++; if (index > 1) { TimeComponent.Instance.AddTimer(1.8f, () => { UIManager.Instance.HideUIPanel(); SceneManager.LoadScene("baidicheng"); TimeComponent.Instance.AddTimer(23f, () => { UIManager.Instance.LoadAndOpenPanel(UIManager.UILayer.Middle); }); }); } } } }