Playing Audio from Unity with NoesisGUI
Hello guys, I have a question regarding audio in NoesisGUI. I'm workin on a system that is similar to a communication wheel where there are different options when clicked such as playing voicelines and eventually generating pings in world. Right now I am focused on implementing different sound queues for my project and I was wondering how I would go about integrating Unity's audio system into the XAML. For example, on the radial menu demo, you have this:
I was wondering if it were possible to bind Unity'd AudioClip, to this. So I have something like this instead
The view model that I am using is a Monobehaviour but I am wondering if I can use Unity's Audio system for some sort of XAML click event and how I would go about doing that?
I'm not sure if the " PlaySoundAction" on the XAML is using the same audio source as Unity (I assume they would be different)?
Any help is appreciated
Code: Select all
<b:DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}" Value="True">
<b:PlaySoundAction Source="Sounds/AudioName.mp3" Volume="1.0" IsEnabled="False"/>
</b:DataTrigger>
Code: Select all
<b:DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}" Value="True">
<b:PlaySoundAction Source="{Binding AudioFile}" Volume="1.0" IsEnabled="False"/>
</b:DataTrigger>
public class Callout
{
public string Name { get; set; }
public ImageSource Icon { get; set; }
public AudioClip AudioFile { get; set; }
}
The view model that I am using is a Monobehaviour but I am wondering if I can use Unity's Audio system for some sort of XAML click event and how I would go about doing that?
I'm not sure if the " PlaySoundAction" on the XAML is using the same audio source as Unity (I assume they would be different)?
Any help is appreciated
Re: Playing Audio from Unity with NoesisGUI
PlayAudio is implemented using PlayClipAtPoint. Source code is available in NoesisProviders.cs.
But yes, nothing stops you from creating your own solution with more control.
Code: Select all
public void PlayAudio(string uri, float volume)
{
Value v;
if (_audios.TryGetValue(uri, out v) && v.audio != null)
{
UnityEngine.AudioSource.PlayClipAtPoint(v.audio, UnityEngine.Vector3.zero, volume);
}
else
{
UnityEngine.Debug.LogError("AudioClip not found '" + uri + "'");
}
}
Who is online
Users browsing this forum: Google [Bot] and 69 guests