unity插件怎么使用golw11怎么使用

在UNITY中使用FMOD插件,直接控制音乐,音效。
FMOD STUDIO的版本与插件要保持一致。
UNITY引入package
FMOD - Edit Setting 3个选项:Project,Single Platform Build,Multiple Platform Build
Project路径指定FMOD工程,其余2个路径指定FMOD导出的bank所在文件夹。
可以指定UNITY工程外路径,如果需要多人同步也可以用Assets\路径 (Mac下用 [/])
指定后插件会自动在Assets/StreamingAssets将bank导入。
注意:导出安卓工程时,FMOD的BANK文件没有被加密放在assets\bin文件夹内,而是直接在assets文件夹下
Live Update选项Enabled时,可以直接在FMOD STUDIO中调试音乐音效。
UNITY内代码部分:
using UnityE
using System.Collections.G
using FMOD.S
using FMODU
public class SoundManager &T&: MonoBehaviour where T: Component{
protected static T _
public static T instance {
if (_instance.IsNull())
_instance = FindObjectOfType&T&();
public static bool DoesInstanceExist {
return instance !=
public BGMPathDefinition[] BGMPathD
protected Dictionary&BGMType, string& BGMPathD
protected BGMType currentAmbientA
//一个声音实例,可控制。
//循环播放的可以创建一个,要手动release, OneShot 为true播放完自动release.
//http://www.fmod.org/docs/content/generated/studio_api_EventInstance.html
//http://www.fmod.org/docs/content/generated/FMOD_Studio_EventDescription_IsOneshot.html
protected EventInstance BGME
////用来读取声音在工程里面的设置信息,用不到
////http://www.fmod.org/docs/content/generated/studio_api_EventDescription.html
//private EventDescription musicD
protected Dictionary&string, EventInstance& loopingSoundEvents = new Dictionary&string, EventInstance&();
protected List&EventInstance& pausedSoundE
protected const int minPathLength = 7;
protected virtual void Awake() {
_instance = GetComponent&T&();
BGMPathDict = new Dictionary&BGMType, string&();
foreach (var ambientAudioDefinition in BGMPathDefinitions) {
BGMPathDict.Add(ambientAudioDefinition.ambientAudioType, ambientAudioDefinition.path);
protected virtual void OnDestroy() {
StopAndReleaseAll();
if (BGMEvent != null) {
BGMEvent.stop(STOP_MODE.IMMEDIATE);
BGMEvent.release();
_instance =
public virtual void StopAndReleaseAll() {
foreach (var sound in loopingSoundEvents.Values) {
if (sound == null)
sound.stop(STOP_MODE.IMMEDIATE);
sound.release();
loopingSoundEvents.Clear();
public virtual void pauseAll() {
pausedSoundEvents = new List&EventInstance&();
foreach (var loopingInstance in loopingSoundEvents.Values) {
if (loopingInstance == null)
PLAYBACK_STATE
loopingInstance.getPlaybackState(out state);
if (state == PLAYBACK_STATE.PLAYING
|| state == PLAYBACK_STATE.STARTING) {
loopingInstance.setPaused(true);
pausedSoundEvents.Add(loopingInstance);
PauseBGM(true);
public virtual void resumeAll() {
PauseBGM(!GameController.Instance.MusicEnable);
if (!GameController.Instance.SFXEnable || pausedSoundEvents == null)
foreach (var pausedSound in pausedSoundEvents) {
pausedSound.setPaused(false);
#region BGM
public virtual void PlayBGM(BGMType type) {
currentAmbientAudio =
if (GameController.Instance.MusicEnable) {
CheckBGMEventInstance();
public virtual void PauseBGM(bool pause) {
if (BGMEvent == null)
CheckBGMEventInstance();
if (BGMEvent != null)
BGMEvent.setPaused(pause);
protected void CheckBGMEventInstance() {
if (BGMPathDict.ContainsKey(currentAmbientAudio)) {
//停止之前的,最好可以通过参数变化背景音乐
if (BGMEvent != null) {
BGMEvent.stop(STOP_MODE.IMMEDIATE);
BGMEvent.release();
BGMEvent = RuntimeManager.CreateInstance(BGMPathDict[currentAmbientAudio]);
BGMEvent.start();
#endregion
#region SFX
/// &summary&
/// 播放一次,不能改变任何参数
/// &/summary&
public virtual void PlaySoundOnce(string sound) {
if (!GameController.Instance.SFXEnable || string.IsNullOrEmpty(sound))
if (sound.Length & minPathLength) {
Logger.Warning(&Wrong Sound Path:& + sound);
RuntimeManager.PlayOneShot(sound);
///// &summary&
///// 目标位置播放一次(位置不变)
///// &/summary&
//public void PlaySoundOnce(string Event, Vector3 position) {
// if (GameController.Instance.SFXEnable)
RuntimeManager.PlayOneShot(Event, position);
///// &summary&
///// 播放一次,位置在attach上(跟着attach移动)
///// &/summary&
//public void PlaySoundOnce(string Event, GameObject attach) {
// if (GameController.Instance.SFXEnable)
RuntimeManager.PlayOneShotAttached(Event, attach);
/// &summary&
/// 循环播放,要Fmod工程内OneShot为false
/// &/summary&
public virtual EventInstance PlayLoopSounds(string sound) {
if (!GameController.Instance.SFXEnable || string.IsNullOrEmpty(sound))
if (sound.Length & minPathLength) {
Logger.Warning(&Wrong Sound Path:& + sound);
if (HavaEventInstance(sound)) {
loopingSoundEvents[sound].start();
return loopingSoundEvents[sound];
var newInstance = RuntimeManager.CreateInstance(sound);
newInstance.start();
loopingSoundEvents[sound] = newI
return newI
/// &summary&
/// 暂停指定循环音效
/// &/summary&
public bool PauseSound(string sound, bool pause = true) {
if (HavaEventInstance(sound)) {
var result = loopingSoundEvents[sound].setPaused(pause && GameController.Instance.SFXEnable);
return result == FMOD.RESULT.OK;
/// &summary&
/// 停止指定循环音效,并释放
/// &/summary&
public bool StopSound(string sound) {
if (HavaEventInstance(sound)) {
var result = loopingSoundEvents[sound].stop(STOP_MODE.IMMEDIATE);
loopingSoundEvents[sound].release();
loopingSoundEvents.Remove(sound);
return result == FMOD.RESULT.OK;
protected bool HavaEventInstance(string sound) {
return !string.IsNullOrEmpty(sound) && loopingSoundEvents.ContainsKey(sound) && !loopingSoundEvents[sound].IsNull();
#endregion
//void OnApplicationPause(bool didPause) {
// if (didPause) {
pauseAll();
resumeAll();
void OnApplicationFocus(bool focus) {
if (focus) {
resumeAll();
pauseAll();
[Serializable]
public class BGMPathDefinition {
public BGMType ambientAudioT
[EventRef]
public enum BGMType {
Mainmenu = 0,
IngameRunning = 20,
FMOD STUDIO的版本与插件要保持一致。
FMOD STUDIO的版本与插件要保持一致。
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:756次
排名:千里之外&>&&>&&>&&>&unity录屏插件
unity录屏插件
上传大小:854KB
一款非常好用的Unity录屏插件
综合评分:0(0位用户评分)
所需积分:3
下载次数:13
审核通过送C币
创建者:mfkbbdx1
创建者:daiyinglang
创建者:nigelyq
课程推荐相关知识库
上传者其他资源上传者专辑
移动开发热门标签
VIP会员动态
android服务器底层网络模块的设计方法
所需积分:0
剩余积分:720
您当前C币:0
可兑换下载积分:0
兑换下载分:
兑换失败,您当前C币不够,请先充值C币
消耗C币:0
你当前的下载分为234。
unity录屏插件
会员到期时间:
剩余下载次数:
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可奖励20下载分
被举报人:
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:}

我要回帖

更多关于 unity 插件使用 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信