151 lines
3.6 KiB
C#
151 lines
3.6 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.Playables;
|
||
using UnityEngine.Timeline;
|
||
using UnityEngine.UI;
|
||
|
||
|
||
public class historyQieHuan : MonoBehaviour
|
||
{
|
||
public Image iconC;
|
||
public Image iconQ;
|
||
public Sprite C0;
|
||
public Sprite C1;
|
||
public Sprite Q0;
|
||
public Sprite Q1;
|
||
public GameObject unT;
|
||
public GameObject unT1;
|
||
public GameObject T;
|
||
public GameObject T1;
|
||
|
||
bool bName = true;
|
||
|
||
public TimelineAsset timeline;
|
||
public PlayableDirector timeplayer;
|
||
|
||
public int trackC1;
|
||
public int trackC2;
|
||
public int trackQ1;
|
||
public int trackQ2;
|
||
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
|
||
}
|
||
public void qie()
|
||
{
|
||
if (bName)
|
||
{
|
||
unT.SetActive(false);
|
||
T.SetActive(true);
|
||
unT1.SetActive(false);
|
||
T1.SetActive(true);
|
||
//unT2.SetActive(false);
|
||
//T2.SetActive(true);
|
||
//unT3.SetActive(false);
|
||
//T3.SetActive(true);
|
||
//unT4.SetActive(false);
|
||
//T4.SetActive(true);
|
||
|
||
ShowTrackGroup("QD");
|
||
HideTrackGroup("GC");
|
||
|
||
iconC.sprite = C0;
|
||
iconQ.sprite = Q0;
|
||
|
||
bName = false;
|
||
}
|
||
else
|
||
{
|
||
unT.SetActive(true);
|
||
T.SetActive(false);
|
||
unT1.SetActive(true);
|
||
T1.SetActive(false);
|
||
//unT2.SetActive(true);
|
||
//T2.SetActive(false);
|
||
//unT3.SetActive(true);
|
||
//T3.SetActive(false);
|
||
//unT4.SetActive(true);
|
||
//T4.SetActive(false);
|
||
|
||
ShowTrackGroup("GC");
|
||
HideTrackGroup("QD");
|
||
|
||
iconC.sprite = C1;
|
||
iconQ.sprite = Q1;
|
||
|
||
bName = true;
|
||
}
|
||
}
|
||
|
||
public void resetQie()
|
||
{
|
||
ShowTrackGroup("GC");
|
||
HideTrackGroup("QD");
|
||
bName = true;
|
||
}
|
||
|
||
public void MuteTrack(int inNum)
|
||
{
|
||
TrackAsset theTrack = timeline.GetOutputTrack(inNum);
|
||
theTrack.muted = true;
|
||
double t0 = timeplayer.time;
|
||
timeplayer.RebuildGraph();
|
||
timeplayer.time = t0;
|
||
timeplayer.Play();
|
||
}
|
||
public void UnMuteTrack(int inNum)
|
||
{
|
||
TrackAsset theTrack = timeline.GetOutputTrack(inNum);
|
||
theTrack.muted = false;
|
||
double t0 = timeplayer.time;
|
||
timeplayer.Stop();
|
||
timeplayer.time = t0;
|
||
timeplayer.Play();
|
||
}
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
||
public void HideTrackGroup(string groupName)
|
||
{
|
||
if (timeplayer == null) return;
|
||
|
||
TimelineAsset timelineAsset = timeplayer.playableAsset as TimelineAsset;
|
||
if (timelineAsset == null) return;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
foreach (var track in timelineAsset.GetOutputTracks())
|
||
{
|
||
if (track.parent != null && track.parent.name == groupName)
|
||
{
|
||
track.muted = true; // <20><><EFBFBD>þ<EFBFBD><C3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>
|
||
}
|
||
}
|
||
}
|
||
|
||
// <20><>ʾ<EFBFBD>ض<EFBFBD><D8B6>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
||
public void ShowTrackGroup(string groupName)
|
||
{
|
||
if (timeplayer == null) return;
|
||
|
||
TimelineAsset timelineAsset = timeplayer.playableAsset as TimelineAsset;
|
||
if (timelineAsset == null) return;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||
foreach (var track in timelineAsset.GetOutputTracks())
|
||
{
|
||
if (track.parent != null && track.parent.name == groupName)
|
||
{
|
||
track.muted = false; // ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
|
||
}
|
||
}
|
||
}
|
||
}
|