Example #1
0
 public void PlayEffectSound(string name, Action <AudioClip> action = null)
 {
     if (effectMusic == null)
     {
         effectMusic = new GameObject("EffectMusic");
     }
     ResourcesManager.GetInstance().LoadResAsync <AudioClip>("Music/effect/" + name,
                                                             (o) => {
         AudioSource effect = effectMusic.AddComponent <AudioSource>();
         effect.clip        = o;
         effect.loop        = false;
         effect.Play();
         effectMusicList.Add(effect);
         if (action != null)
         {
             action(o);
         }
     });
 }
Example #2
0
        /// <summary>
        /// 获取物体 异步加载
        /// </summary>
        /// <param name="name"></param>
        /// <param name="loadComplete"></param>
        /// <returns></returns>
        public GameObject GetGameObject(string name, Action <GameObject> loadComplete)
        {
            GameObject ob = null;

            if (poolDir.ContainsKey(name) && poolDir[name].poolList.Count != 0)
            {
                ob = poolDir[name].GetObj();
                loadComplete(ob);
            }
            else
            {
                ResourcesManager.GetInstance().LoadResAsync <GameObject>(name, (e) =>
                {
                    e.name = name;
                    loadComplete(e);
                });
            }
            return(ob);
        }
Example #3
0
 /// <summary>
 /// 播放背景音乐
 /// </summary>
 /// <param name="name"></param>
 public void PlayBackgroundMusic(string name, float volume, Action <AudioClip> action = null)
 {
     if (backgroundMusic == null)
     {
         GameObject ob = new GameObject("BackgroundMusic");
         backgroundMusic = ob.AddComponent <AudioSource>();
     }
     ResourcesManager.GetInstance().LoadResAsync <AudioClip>("Music/bgm/" + name,
                                                             (o) => {
         backgroundMusic.clip   = o;
         backgroundMusic.volume = volume;
         backgroundMusic.loop   = true;
         backgroundMusic.Play();
         if (action != null)
         {
             action(o);
         }
     });
 }
Example #4
0
        /// <summary>
        /// 获取物体 同步加载
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public GameObject GetGameObject(string name)
        {
            GameObject ob = null;

            if (poolDir.ContainsKey(name))
            {
                //存在但没库存
                if (poolDir[name].poolList.Count == 0)
                {
                    ob      = ResourcesManager.GetInstance().LoadRes <GameObject>(name);
                    ob.name = name;
                }
                else
                {
                    ob = poolDir[name].GetObj();
                }
            }
            else
            {
                ob      = ResourcesManager.GetInstance().LoadRes <GameObject>(name);
                ob.name = name;
            }
            return(ob);
        }