Exemple #1
0
//        public void LoadAudioBundle(string path)
//        {
//            if (m_Cache == null)
//            {
//                m_Cache = gameObject.AddComponent<AudioCache>();
//            }
//
//            m_Cache.LoadBundle(path);
//        }
//
//        public void LoadAdditionalBundle(AssetBundle bundle)
//        {
//            if (m_Cache == null)
//            {
//                m_Cache = gameObject.AddComponent<AudioCache>();
//            }
//
//            m_Cache.LoadAdditionalBundle(bundle);
//        }
//
//        public void UnloadAdditionalBundles()
//        {
//            if (m_Cache != null)
//            {
//                m_Cache.UnloadAdditionalBundles();
//            }
//        }

        protected override void Awake()
        {
            base.Awake();

            m_Preferences = AudioPreferences.Instance;

            // So audio time starts from zero
            m_CustomTimePausedDuration = DateTime.Now.Ticks;

            AudioData.ReconstructTreeChildren();
            m_Leafs = AudioData.TreeData.GetLeafDictionary();
            m_ClipsLastPlayedTimes         = new Dictionary <int, float>(1000);
            m_CurrentPlayingCategoryCounts = new Dictionary <int, int>(100);
            m_audioMixerSnapShots          = new Dictionary <string, AudioMixerSnapshot>();

            PrepareLeafPrefixes();

            m_MainMixer = m_AudioData.TreeData.DefaultBus.audioMixer;
        }
        public static AudioManagerData LoadInstanceData()
        {
            AudioPreferences p = AudioPreferences.Instance;

#if UNITY_2018_3_OR_NEWER
            var go = PrefabUtility.LoadPrefabContents(p.AudioManagerDataPrefabPath);
            AudioManagerData data = go.GetComponent <AudioManagerData>();
#else
            AudioManagerData data = AssetDatabase.LoadAssetAtPath <AudioManagerData>(p.AudioManagerDataPath);
#endif

            if (data == null)
            {
                return(null);
            }

            data.ReconstructTreeChildren();
            return(data);
        }