TipPanel.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using System.Collections.Generic;
  2. using Mono.UI.Core;
  3. using UnityEngine;
  4. using UnityEngine.Playables;
  5. using UnityEngine.SceneManagement;
  6. using UnityEngine.Timeline;
  7. using UnityEngine.UI;
  8. namespace Mono
  9. {
  10. [UIBinding(prefab = "TipPanel")]
  11. public class TipPanel : UIPanel
  12. {
  13. public Text Text_00;
  14. public Typewriter Text_01;
  15. public override void GetUIData()
  16. {
  17. Text_00 = UIData.Get<Text>("Text_00");
  18. Text_01 = UIData.Get<Typewriter>("Text_01");
  19. }
  20. public override void Show()
  21. {
  22. base.Show();
  23. index = 0;
  24. Text_01.StringContent = "龙泉剑\n在白帝城偶遇诗仙李白获赠的随身佩剑";
  25. Text_01.SetContent();
  26. }
  27. private int index = 0;
  28. /// <summary>
  29. /// 所有的轨道组
  30. /// </summary>
  31. public List<TrackAsset> trackGroups = new List<TrackAsset>();
  32. public void ResetTrackAsset(PlayableDirector pd)
  33. {
  34. trackGroups.Clear();
  35. TimelineAsset ta = (TimelineAsset)pd.playableAsset;
  36. for (int i = 0; i < ta.rootTrackCount; i++)
  37. {
  38. TrackAsset trackAsset = ta.GetRootTrack(i);
  39. trackAsset.muted = true;
  40. trackGroups.Add(trackAsset);
  41. }
  42. }
  43. private void MuteAll()
  44. {
  45. foreach (TrackAsset trackGroup in trackGroups)
  46. {
  47. // trackGroup.
  48. trackGroup.muted = true;
  49. }
  50. }
  51. public void DBJNext()
  52. {
  53. PlayableDirector playableDirector = GameObject.Find("timeline").gameObject.GetComponent<PlayableDirector>();
  54. ResetTrackAsset(playableDirector);
  55. MuteAll();
  56. foreach (var trackGroup in trackGroups)
  57. {
  58. switch (index)
  59. {
  60. case 0:
  61. if (trackGroup.name == "1")
  62. {
  63. trackGroup.muted = false;
  64. }
  65. break;
  66. case 1:
  67. if (trackGroup.name == "2")
  68. {
  69. trackGroup.muted = false;
  70. }
  71. break;
  72. }
  73. }
  74. // foreach (var playableAssetOutput in playableDirector.playableAsset.outputs)
  75. // {
  76. //
  77. // TrackAsset asset = playableAssetOutput.sourceObject as TrackAsset;
  78. // asset.muted = true;
  79. // }
  80. //
  81. //
  82. // foreach (var playableAssetOutput in playableDirector.playableAsset.outputs)
  83. // {
  84. // TrackAsset asset = playableAssetOutput.sourceObject as TrackAsset;
  85. //
  86. //
  87. // switch (index)
  88. // {
  89. // case 0:
  90. //
  91. // if (asset.GetGroup().name == "1")
  92. // {
  93. // asset.muted = false;
  94. // }
  95. //
  96. // break;
  97. //
  98. // case 1:
  99. //
  100. // if (asset.GetGroup().name == "2")
  101. // {
  102. // asset.muted = false;
  103. // }
  104. //
  105. //
  106. // break;
  107. // }
  108. // }
  109. playableDirector.time = 0;
  110. playableDirector.Play();
  111. index++;
  112. if (index > 1)
  113. {
  114. TimeComponent.Instance.AddTimer(1.8f, () =>
  115. {
  116. UIManager.Instance.HideUIPanel<TipPanel>();
  117. SceneManager.LoadScene("baidicheng");
  118. TimeComponent.Instance.AddTimer(23f, () => { UIManager.Instance.LoadAndOpenPanel<ChatPanel>(UIManager.UILayer.Middle); });
  119. });
  120. }
  121. }
  122. }
  123. }