Esempio n. 1
0
        /// <summary>
        /// 设置背景音乐
        /// </summary>
        /// <param name="bgmName">音乐名</param>
        public void SetBGM(string bgmName)
        {
            if (bgmName == mBGMName)
            {
                return;
            }
            if (string.IsNullOrEmpty(mBGMName) == false)
            {
                ResourceUtil.Unload(mBGMName);
            }

            mAudioSource.clip = ResourceUtil.Load <AudioClip>(bgmName);
            mAudioSource.Play();
        }
Esempio n. 2
0
        private static GOInfo GetGOInfo(string name)
        {
            var iter = goTable.GetEnumerator();

            while (iter.MoveNext())
            {
                GOInfo info = iter.Current.Key;
                if (info.name == name)
                {
                    return(info);
                }
            }

            // 没有就创建
            GOInfo goInfo = new GOInfo()
            {
                name = name, prefab = ResourceUtil.Load <GameObject>(name)
            };
            Queue <GameObject> queue = new Queue <GameObject>();

            goTable.Add(goInfo, queue);
            return(goInfo);
        }
Esempio n. 3
0
 /// <summary>
 /// 播放一段声音
 /// </summary>
 /// <param name="soundName">声音名</param>
 public void PlaySound(string soundName, float volumn = 1f)
 {
     mAudioSource.PlayOneShot(ResourceUtil.Load <AudioClip>(soundName), volumn * this.volumn);
     ResourceUtil.Unload(soundName);
 }
Esempio n. 4
0
        public static T Create <T>(string prefabName, Vector3 generatePos) where T : Entity
        {
            GameObject go = ResourceUtil.Load <GameObject>(prefabName).Instantiate().Position(generatePos);

            return(Create <T>(go));
        }
Esempio n. 5
0
 public void Awake()
 {
     GameObject = ResourceUtil.Load <GameObject>("ResHold").Instantiate();
     GameObject.AddComponent <ComponentView>().Component = this;
     Collector = GameObject.GetComponent <ReferenceCollector>();
 }
Esempio n. 6
0
 /// <summary>
 /// 播放一段声音
 /// </summary>
 /// <param name="soundName">声音名</param>
 public void PlaySound(string soundName)
 {
     mAudioSource.PlayOneShot(ResourceUtil.Load <AudioClip>(soundName));
     ResourceUtil.Unload(soundName);
 }