Questions et réponses de la communauté

Bienvenue sur le forum de questions et réponses d'Audiokinetic, propulsé par la communauté. C'est l'endroit où les utilisateurs de Wwise et Strata s'entraident. Pour obtenir une aide directe de notre équipe, veuillez utiliser la page « Tickets de soutien ». Pour signaler un bug, utilisez l'option Bug Report dans l'Audiokinetic Launcher. (Veuillez noter que les rapports de bug soumis au forum questions-réponses seront rejetés. L'utilisation de notre système de rapport de bug dédié garantit que votre rapport est vu par les bonnes personnes et a les meilleures chances d'être corrigé.)

Pour obtenir rapidement les meilleures réponses, suivez ces conseils lorsque vous posez une question :

  • Soyez précis : qu'essayez-vous de réaliser ou quel est le problème spécifique que vous rencontrez ?
  • Pensez à inclure les détails importants : incluez des détails tels que les versions de Wwise et du moteur de jeu, le système d'exploitation, etc.
  • Expliquez ce que vous avez essayé de faire : indiquez aux autres les mesures que vous avez déjà prises pour essayer de résoudre le problème.
  • Concentrez-vous sur les faits : décrivez les aspects techniques de votre problème. Se concentrer sur le problème aide les autres personnes à trouver rapidement une solution.

0 votes

Original question posted on Wwise Wwizards and Wwitches

Posted by Benedict S.
Hey everyone, got what might be a really simple Unity integration question. I'm trying to toggle between engine states "on" and "off" using one key, and I'm trying to check what the current state is before setting it to the other. I'm struggling to work out what do here – I've tried using akSoundEngine.GetState(), but I have no idea how to use it.
The first parameter is the state group as a string, but the second is "out uint out_rState" according to VS Code. I'm not great with Unity, so I'm wondering what on earth this integer might be that I need to feed in – does anyone have any ideas?
Here's the one page I've found so far which even mentions akSoundEngine.GetState(). Cheers

dans General Discussion par Mads Maretty S. (Audiokinetic) (40.2k points)

1 Réponse

0 votes

Hello Benedict, 

Originally, I advised you to use Wwise-Types, but that was a mistake. Wwise-type States are just specific State values and so there's no GetValue or GetState function on it. That said, you can still create two Wwise-type States, which would give you the pickers in the Inspector, and then get the Group ID from it. Something like this... 


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SomeScript : MonoBehaviour
{
    public AK.Wwise.State State01;
    public AK.Wwise.State State02;
    private void Start()
    {
        // If not set, the initial State will be "None".
        State01.SetValue();
    }

    void Update()
    {
        // Button input check
        if (Input.GetKeyDown(KeyCode.Space)) {            

            uint currentState = 0; // variable to store the ID in.
            // Since the Wwise-types only refer to specific state values,
            // you will need to AkSoundEngine.GetState() to get the global one.
            // That said, you can still use the ID from the Wwise-Types.
            AkSoundEngine.GetState(State01.GroupId, out currentState);
            print(currentState); // just delete if you've tested it out.

            if (currentState == State01.Id)
            {
                State02.SetValue();
                print("Set State02"); // just delete if you've tested it out.
            }
            else if (currentState == State02.Id)
            {
                State01.SetValue();
                print("Set State01"); // just delete if you've tested it out.
            }
        }
    }
}


As for the 'out uint out_rState' you just need to declare a uint property first, so you can store the value you get back. That value will be the ID of that State, and you can e.g. use it to search in your SoundBank.txt file and see what specific State it is. 

par Mads Maretty S. (Audiokinetic) (40.2k points)
...