版本

menu_open

Using Wwise Custom Platforms in Unity

By default, the Wwise Unity Integration assumes the platforms defined in the associated Wwise project all have the default name. If you wish to give your platforms a custom name or define multiple custom platforms for a base platform, you will need to create a C# script to handle this.

Note.gif

Note: This page assumes that the subfolder in which your SoundBanks are generated has the same name as your platform. If this is not the case, note that the string returned by the GetPlatformName method is actually used as the in-game SoundBank subfolder name.

Custom platforms

The default platform resolving script can be found in the file UNITY_PROJECT_ROOT/Assets/Wwise/Deployment/Components/AkBasePathGetter.cs. As seen in the GetPlatformName() method, default names for all platforms are returned by this function. If you wish to use your own platform names, please follow these steps:

  1. Create a new C# script outside of the UNITY_PROJECT_ROOT/Assets/Wwise folder, and name it AkCustomPlatformNameGetter.cs.
  2. Inside this script, create the public AkCustomPlatformNameGetter class.
  3. Inside the AkCustomPlatformNameGetter class, add a public static function named GetPlatformName, returning a string.
  4. Write your own code to return the correct platform names.
  5. Before building your game for your target platform, ensure the SoundBanks for all of your custom platforms for a specific base platforms are copied to the StreamingAssets folder. See pg_streamassets for more information.

Example

This example will only cover a use case for the iOS platform. In the example, you wish to have three different custom platforms for the iOS base platform: one for iPods, one for iPhones, and one for iPads.

  1. First, in the Wwise project, you will add three different platforms in the platform manager: "iPod", "iPhone", and "iPad". (For more information on the Platform Manager in Wwise, see the Wwise Help > Setting Up Your Projects > Managing Platforms section of the Wwise documentation).
  2. Then, in Unity, create a C# script in UNITY_PROJECT_ROOT/Assets, and name it AkCustomPlatformNameGetter.cs. The contents of this file will be like this:
    public class AkCustomPlatformNameGetter
    {
        static public string GetPlatformName()
        {
    #if UNTIY_IOS
            switch(UnityEngine.iOS.Device.generation)
            {
                case UnityEngine.iOS.DeviceGeneration.iPhone:
                case UnityEngine.iOS.DeviceGeneration.iPhone3G:
                case UnityEngine.iOS.DeviceGeneration.iPhone3GS:
                case UnityEngine.iOS.DeviceGeneration.iPhone4:
                case UnityEngine.iOS.DeviceGeneration.iPhone4S:
                case UnityEngine.iOS.DeviceGeneration.iPhone5:
                case UnityEngine.iOS.DeviceGeneration.iPhone5C:
                case UnityEngine.iOS.DeviceGeneration.iPhone5S:
                case UnityEngine.iOS.DeviceGeneration.iPhone6:
                case UnityEngine.iOS.DeviceGeneration.iPhone6Plus:
                case UnityEngine.iOS.DeviceGeneration.iPhoneUnknown:
                    return "iPhone";
    
                case UnityEngine.iOS.DeviceGeneration.iPodTouch1Gen:
                case UnityEngine.iOS.DeviceGeneration.iPodTouch2Gen:
                case UnityEngine.iOS.DeviceGeneration.iPodTouch3Gen:
                case UnityEngine.iOS.DeviceGeneration.iPodTouch4Gen:
                case UnityEngine.iOS.DeviceGeneration.iPodTouch5Gen:
                case UnityEngine.iOS.DeviceGeneration.iPodTouchUnknown:
                    return "iPod";
    
                case UnityEngine.iOS.DeviceGeneration.iPad1Gen:
                case UnityEngine.iOS.DeviceGeneration.iPad2Gen:
                case UnityEngine.iOS.DeviceGeneration.iPad3Gen:
                case UnityEngine.iOS.DeviceGeneration.iPadMini1Gen:
                case UnityEngine.iOS.DeviceGeneration.iPad4Gen:
                case UnityEngine.iOS.DeviceGeneration.iPadAir1:
                case UnityEngine.iOS.DeviceGeneration.iPadMini2Gen:
                case UnityEngine.iOS.DeviceGeneration.iPadMini3Gen:
                case UnityEngine.iOS.DeviceGeneration.iPadAir2:
                case UnityEngine.iOS.DeviceGeneration.iPadUnknown:
                    return "iPad";
    
                default:
                    return "iPhone";
            }
    #endif
            return string.Empty;
        }
    }
    
    Note.gif
    Note: If your custom GetPlatformName method returns an empty string, the default platform name for the current active Unity platform will be used.
  3. In Wwise, generate the SoundBanks for all three platforms: "iPhone", "iPod", and "iPad". Copy the three resulting folders to UNITY_PROJECT_ROOT/Assets/StreamingAssets/Audio/GeneratedSoundBanks.
  4. In Unity, build your game for the iOS platform.
  5. From now on, a different set of SoundBanks will be used depending on the type of device used.
Generated on Tue Nov 21 09:21:29 2017 for Wwise Unity Integration by  doxygen 1.6.3

此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅