Esempio n. 1
0
 void Awake()
 {
     //if (Instance != null) {
     //	Destroy (gameObject);
     //	return;
     //}
     if (Instance != null)
     {
         Instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
Esempio n. 2
0
            internal static void InitSound(SoundAssetBundleHelper SoundHelper)
            {
                Debug.Log("Init Sound");
                soundHelper = SoundHelper;
                //Debug.LogError("InitSound  length= " + soundHelper.MapSound.Count);
                enable         = PlayerPrefs.GetInt("sound_enable", 1);
                enable_bgsound = PlayerPrefs.GetInt("bgsound_enable", 1);

                //gameObject.AddComponent<AudioListener>(); Tam thoi comment 25/8/2016 by ronaldo

                //load file trong thu muc resource

                Dictionary <string, SoundId> Maps = new Dictionary <string, SoundId>();

                foreach (var field in typeof(SoundId).GetFields())
                {
                    //Debug.LogError("------------------------------ InitSOund------------------------");
                    var attribute = (StringValueAttribute[])field.GetCustomAttributes(typeof(StringValueAttribute), false);

                    if (attribute.Length == 0)
                    {
                        continue;
                    }
                    Maps[attribute[0].Value] = (SoundId)field.GetValue(null);
                    //Debug.LogError("------------------------------ InitSOund------------------------" + Maps[attribute[0].Value]);
                }


#if UNITY_EDITOR
                string myPath = "Assets/Resources/Sounds";
                //                GetSoundFilesFromDirectory(gameObject, Maps, myPath);
                LoadAllSoundFromConfig(soundHelper.gameObject, Maps);
#else
                LoadAllSoundFromConfig(soundHelper.gameObject, Maps);
#endif

                is_init_done = true;
            }
Esempio n. 3
0
 void OnDestroy()
 {
     Instance = null;
 }