Sounds
How to play sounds for Inventool.
Sounds can be handled entirely with Events. The example below teaches you how you can play your own audio clips when an Inventool button is clicked.
using Esper.Inventool.UI;
using UnityEngine;
using UnityEngine.UIElements;
public class SoundEventExample : MonoBehaviour
{
[SerializeField]
private AudioClip myAudioClip;
private void Start()
{
// Register the callback
Inventool.onButtonClicked.AddListener(OnButtonClicked);
}
/// <summary>
/// Plays a sound.
/// </summary>
/// <param name="button">The button that was clicked.</param>
private void OnButtonClicked(Button button)
{
// Play the audio clip
AudioSource.PlayClipAtPoint(myAudioClip, transform.position);
}
}
Last updated