Wwise Authoring is currently not compatible with macOS Catalina. We recommend that you don't upgrade your operating system until further notice.

Leçon 1

Table des matières

Loading a SoundBank

To post a Wwise Event, the Event must first be added to a SoundBank and loaded into memory.

[Tip]

Please visit the Wwise Certification 101 for an introduction on adding Wwise Events to SoundBanks.

To load a SoundBank in Unity, Wwise needs to know at least two pieces of information:

  1. The referenced game object.

  2. The Trigger mechanism.

This information is defined in via script. In the Wwise Unity Integration, you can add a pre-constructed AkBank script to a game object that will then become the attached game object, satisfying step 1. In the AkBank component, you can select various methods for loading the SoundBank in the Load On property, satisfying step 2.

[Note]

When adding a script to a game object, it is added as a component.

For the Wwise Adventure Game, the majority of the sounds exist within the General SoundBank. Before any of those sounds can be played at runtime, the SoundBank must first be loaded. The AkBank component can be configured to load the General SoundBank based on any number of different actions in the game, but it makes sense to go ahead and simply load this SoundBank before the the game starts in Awake. All sounds can then be posted when the game starts in Start.In the following steps, we'll load the General SoundBank in the Wwise Adventure Game and make sure it's loaded in Awake.

  1. In the Unity menu, select Audiokinetic > Certifications > 301 > Lesson 1 > Loading a SoundBank.

    [Note]

    The 'Loading a SoundBank' Scene is a copy of the Main Scene in the Wwise Adventure Game. This course has several scenes prepared for you, allowing space for the elements that you will add or modify during the exercise. It also gives you a Scene that you can experiment with, without affecting the Main Scene.

  2. In the Hierarchy view in Unity, expand Wwise and select the GeneralSoundBanks game object.

    When Unity initializes, it will look at all scripts added to all game objects. Should it find any scripts with functions listed in Unity's Script Lifecycle Flowchart, it will call these functions in a certain order. As such, to follow that execution order, the AkBank script added to the GeneralSoundBanks game object can be assigned to Awake, which will automatically be evoked when Unity initializes.

    To quickly and conveniently add an AkBank script to a game object, you can use the Wwise Picker. This standard Wwise Unity Integration feature provides a list of available objects in the connected Wwise project, like Events, SoundBanks, or Switches. When dragging one of these Wwise objects onto a game object, the corresponding integration component(s) will be added, and the object will automatically be assigned to it.

    [Note]

    To open the Wwise Picker, go to the Unity menu's Window > Wwise Picker. Find more information about the Wwise Picker at https://www.audiokinetic.com/library/edge/?source=Unity&id=unity__picker.html.

  3. In the Wwise Picker, expand SoundBanks > Default Work Unit > General and drag the General SoundBank onto the GeneralSoundBanks game object in the Inspector.

    [Note]

    Alternatively, you can use the Add Component to add the AkBank script and then assign the Bank Name the corresponding Soundbank.

    Take a look at the Inspector.

    Here you'll see that the AkBank script is now added to the GeneralSoundBanks game object, and in the Bank Name you will see the General SoundBank has been selected. By default, the Load On property is set to Start, but in the Wwise Adventure Game Events would already be posted at Start, so you need to change the execution order to load the SoundBank when the game is loading on Awake. By setting the Load On property to nothing, you deselect all other selected Triggers, ensuring that you are not both selecting Start and Awake.

    [Tip]

    If no Events were loaded in Start, you could easily load the SoundBank in Start. Loading SoundBanks in Awake and posting Events in Start is a very simple way to ensure your SoundBanks are loaded before the Events are posted, but this could very easily be different in another Unity project.

  4. Open the Load On property and select Nothing.

  5. Open it again and select Awake.

    That's it! Once the Wwise sound engine is initialized, the General SoundBank will load. Before profiling the game with Wwise, let's generate SoundBanks.

  6. Switch to Wwise and in the Layouts menu, select SoundBank.

  7. In the SoundBank Manager, make sure the Default Work Unit is enabled, along with your current platform ( Windows or Mac) and the English (US) language.

  8. Press Generate.

    Next, let's connect the Profiler and click Play, to ensure the SoundBank is loaded. As long as you have the Wwise Adventure Game open and the Wwise sound engine running, you can connect it, even while not in Play mode.

  9. Switch back to Wwise and, from the Layouts menu, select Profiler.

  10. In the Toolbar, click Remote…

  11. From the Remote Connections view's Available tab, select Wwise Adventure Game (Editor).

  12. Click Connect.

  13. In Unity, click Play.

    Once you have entered Play mode, the Profiler will know which SoundBanks have been loaded already; you can immediately verify this in the Wwise profiler.

  14. Press ESC to open the WAG (Wwise Adventure Game) menu and click Play again to exit Play mode.

  15. Switch to Wwise, and in the Advanced Profiler, select the Memory tab.

  16. In the Performance Monitor, drag the time cursor backwards until you see the General SoundBank in the Memory tab.

    In the Advanced Profiler, you will find the General SoundBank in the list along with all other memory allocations from Wwise.

    By appearing in the Memory tab's list, you ensure that the SoundBank is loaded into memory, and can now post Events from that SoundBank.

[Note]

As mentioned in Lesson 0, all changes made in Play mode will not be saved. It is therefore extremely important that you exit Play mode before continuing to another section or exercise, so you will not lose your changes. This exercise includes an exiting Play mode warning, but the next section will expect you to know to disable the play button (not in Play mode).

First step complete. Next, playing a sound!