Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

Dynamically assign name to event

0 votes
In Unity, how can I set the Name of an AkEvent in code? I'm trying to avoid manually creating a GameObject for each Event.
asked Feb 17, 2020 in General Discussion by Carlos L. (130 points)

1 Answer

0 votes

Hey Carlos, 

How would you like to set it? You could override the "Name: " (actually it's called data) property with a Wwise-Type Event, so you'll still be able to select the Event in the inspector of the script you're instantiating from. Something like this...

public AK.Wwise.Event WwiseTypeEvent;
void Awake(){
    AkEvent AkE = gameObject.AddComponent<AkEvent>();
    AkE.data = WwiseTypeEvent;
}

Let me know if this is what you need. 

answered Feb 18, 2020 by Mads Maretty S. (Audiokinetic) (38,280 points)
Hello Mads,

Thanks for your answer I'm trying to avoid setting the event on the inspector so I can use the same code for any event, I made it work using the following code:

AK.Wwise.Event soundEvent = new AK.Wwise.Event();
soundEvent.SetupReference("Attack", Guid.Empty);
soundEvent.Post(gameObject);

But I'm not sure if this is the best approach, I'm still new to Wwise in Unity.
...