Sounds
How to play sounds for Inventool.
Playing sounds for Inventool's UI can be handled through 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
// Use onUGUIButtonClicked for uGUI
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