安装FMOD Studio Unity Integration(Installing with the FMOD Studio Unity Integration)
FMOD Studio Unity Integration是一个Unity插件,通过该插件可在Unity游戏中使用FMOD技术。
The FMOD Studio Unity Integration is a Unity plugin which allows the use of FMOD in Unity games.
兼容性(Compatibility)
对于Windows(32/64位)、OS X和 Android上的工程来说,Oculus Spatializer Plugin (OSP) for FMOD能够兼容FMOD Studio Unity Integration。目前FMOD Studio Unity Integration有两个版本可用,分别是2.0和Legacy。OSP for FMOD能够和以下版本兼容:
The Oculus Spatializer Plugin (OSP) for FMOD is compatible with FMOD Studio Unity Integration for projects targeting Windows (32/64 bit), OS X, and Android. Two versions of the FMOD Studio Unity Integration are currently available: 2.0 and Legacy. The OSP for FMOD is compatible with:
- 2.0 (1.07.04或更高版本)
- Legacy 版本1.07.03
Legacy Integration安装教程(Legacy Integration Installation)
- 根据以下链接说明设置Legacy Integration:http://www.fmod.org/documentation/#content/generated/engine_unity/overview.html
- 根据链接说明使用FMOD Studio中的OSP:https://developer.oculus.com/documentation/audiosdk/latest/tasks/osp-fmod-usage/
- 在Unity Editor中打开你的工程,进入Assets > Import > Custom Package,并选择AudioSDK\Plugins\FMOD\Unity中的OculusSpatializerFMODUnity.unitypackage导入到工程中。
- 将OvrFMODGlobalSettings.cs加到场景里的一个GameObject中。你可以在主场景中使用空的GameObject。
- 在Project view中选择FMOD_Listener script,加到主场景的对象中。在Unity Inspector view中,Size of Plugin Paths的值加1,并在新元素中添加ovrfmod。
- 只用于OS X平台:在FMOD_Listener.cs中,LoadPlugins()方法通过OCULUS中start/end标签中的代码,修改循环中的体结构:
- Follow instructions for setting up the Legacy Integration here: http://www.fmod.org/documentation/#content/generated/engine_unity/overview.html
- Follow instructions for using the OSP in FMOD Studio: https://developer.oculus.com/documentation/audiosdk/latest/tasks/osp-fmod-usage/
- Open your project in the Unity Editor. Then select Assets > Import > Custom Package, and select OculusSpatializerFMODUnity.unitypackage in AudioSDK\Plugins\FMOD\Unity to import it into your project.
- Attach OvrFMODGlobalSettings.cs to a GameObject in the scene. You may use an empty GameObect in the root of the scene.
- In the Project view, select the FMOD_Listener script, which should be attached to an object in the root of the scene. In the Unity Inspector view, increment the Size of Plugin Paths by one, and add ovrfmod in the new element.
- OS X platform only: In FMOD_Listener.cs, in LoadPlugins(), modify the body of the foreach loop with the following code inside the OCULUS start/end tags:
foreach (var name in pluginPaths)
{
// OCULUS start
var path = pluginPath + "/";
if(name.Equals("ovrfmod") && (Application.platform == RuntimePlatform.OSXEditor ||
Application.platform == RuntimePlatform.OSXPlayer ||
Application.platform == RuntimePlatform.OSXDashboardPlayer) )
{
path += (name + ".bundle");
FMOD.Studio.UnityUtil.Log("Loading plugin: " + path);
}
else
{
path += GetPluginFileName(name);
FMOD.Studio.UnityUtil.Log("Loading plugin: " + path);
#if UNITY_5 && (UNITY_64 || UNITY_EDITOR_64)
if (!System.IO.File.Exists(path))
{
path = pluginPath + "/" + GetPluginFileName(name + "64");
}
#endif
#if !UNITY_METRO
if (!System.IO.File.Exists(path))
{
FMOD.Studio.UnityUtil.LogWarning("plugin not found: " + path);
}
#endif
}
// OCULUS end
uint handle;
FMOD.RESULT res = sys.loadPlugin(path, out handle);
ERRCHECK(res);
}
现在,你可以在Unity应用运行时,导入和播放使用了OSP的FMOD事件。
Now you should be able to load and play FMOD Events that use the OSP in your Unity application runtime.
2.0 Integration安装教程(2.0 Integration Installation)
如果你的代码需要从Legacy Integration上迁移过来,请参考链接中的FMOD代码迁移教程:http://www.fmod.org/documentation/#content/generated/engine_new_unity/migration.html
If you are migrating from the Legacy Integration, please follow FMOD’s migration guide here: http://www.fmod.org/documentation/#content/generated/engine_new_unity/migration.html
若不需要迁移,则进行以下几个步骤(Otherwise, take the following steps):
- 根据以下链接说明设置2.0 Integration:http://www.fmod.org/documentation/#content/generated/engine_new_unity/overview.html
- 根据以下链接说明使用FMOD Studio中的OSP:https://developer.oculus.com/documentation/audiosdk/latest/tasks/osp-fmod-usage/
- 在Unity Editor中打开你的工程,进入Assets > Import > Custom Package,并选择AudioSDK\Plugins\FMOD\Unity中的OculusSpatializerFMODUnity.unitypackage导入到工程中。
- 将OvrFMODGlobalSettings.cs的Start()方法中以下代码。
FMOD.System sys = null;
FMOD_StudioSystem.instance.System.getLowLevelSystem(out sys);
改为:
FMOD.System sys = FMODUnity.RuntimeManager.LowlevelSystem;
5.进入Project标签下的FMOD Settings,点击Add Plugin按钮,并在新的文本框中添加ovrfmod。
现在,你可以在Unity应用运行时,导入和播放使用了OSP的FMOD事件。
You should now be able to load and play FMOD Events that use the OSP in your Unity application runtime.
在FMOD中进行OSP版本迁移(OSP Version Migration in FMOD)
为了将代码迁移到新版的Oculus Spatializer Plugin for FMOD中,建议遵循以下几步:
To migrate to a new version of the Oculus Spatializer Plugin for FMOD, it is recommended to follow these steps:
- 从Audio SDK中复制新版的ovrfmod.dll文件替换掉你已有的FMOD Studio工程目录下Plugins文件夹中的同名文件。
- 如果Plugins文件夹中有一个名为ovrfmod32.dll的文件,删除并复制ovrfmod.dll文件到该目录下。
- 从Audio SDK中复制新版的ovrfmod.dll和ovrfmod.lib(选择相应的32位或64位文件)替换掉应用目录下的同名文件。(注意:现在32位和64位的插件都名为ovrfmod,32和64的后缀已经弃用)。
- 打开FMOD Studio工程并编译声音库。
- 发布应用,并加载最新的编译库。
- Copy the new version of ovrfmod.dll from the Audio SDK over the existing version in the Plugins folder of your FMOD Studio project directory.
- If the Plugins folder contains a file named ovrfmod32.dll, delete it and copy ovrfmod.dll into the folder.
- Copy the new versions of ovrfmod.dll and ovrfmod.lib (32-bit or 64-bit, as appropriate) from the Audio SDK over the existing versions in your application directory. (Note that both the 32-bit and 64-bit plugins are now named ovrfmod, the 32 and 64 suffixes have been dropped).
- Open your FMOD Studio project and build sound banks.
- Launch your application and load the newly built banks.