/// <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(); }
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); }
/// <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); }
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)); }
public void Awake() { GameObject = ResourceUtil.Load <GameObject>("ResHold").Instantiate(); GameObject.AddComponent <ComponentView>().Component = this; Collector = GameObject.GetComponent <ReferenceCollector>(); }
/// <summary> /// 播放一段声音 /// </summary> /// <param name="soundName">声音名</param> public void PlaySound(string soundName) { mAudioSource.PlayOneShot(ResourceUtil.Load <AudioClip>(soundName)); ResourceUtil.Unload(soundName); }