public Dictionary <AudioSource, byte> audioSourceStateDict = new Dictionary <AudioSource, byte>(); //紀錄所有AudioSource的目前狀態(0 = 完全停止 / 1 = 撥放中 / 2 = 停止中) void Awake() { if (_instance == null) { _instance = this; //設定單例 } }
private AudiosPack audiosPack; //音訊設定包 //-------------------------------------------------------------------------------------------------------------- void Awake() { if (_instance == null) { _instance = this; //設定單例 } else { Destroy(this.gameObject); } audiosPack = this.GetComponent <AudiosPack>(); audiosPack.SetAudioSourceDict(); //初始化字典 DontDestroyOnLoad(this); //跨場景物件 }