76 lines
1.6 KiB
C#
76 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using AlicizaX.InputGlyph;
|
|
using AlicizaX.UI;
|
|
using AlicizaX.UI.Extension;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TestAudioPlay : MonoBehaviour
|
|
{
|
|
public AudioSource audioSource;
|
|
[SerializeField] private UXHotkeyButton[] hotButtons;
|
|
public class UXAuditoHelper : IUXAudioHelper
|
|
{
|
|
private AudioSource _audioSource;
|
|
|
|
public UXAuditoHelper(AudioSource audioSource)
|
|
{
|
|
_audioSource = audioSource;
|
|
}
|
|
|
|
public void PlayAudio(AudioClip clip)
|
|
{
|
|
_audioSource.PlayOneShot(clip);
|
|
}
|
|
|
|
public void PlayAudio(string clipName)
|
|
{
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
InputDeviceWatcher.OnDeviceChanged += OnInputDeviceChanged;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
InputDeviceWatcher.OnDeviceChanged -= OnInputDeviceChanged;
|
|
}
|
|
|
|
private void OnInputDeviceChanged(InputDeviceWatcher.InputDeviceCategory obj)
|
|
{
|
|
Debug.Log($"InputDevice:{obj}");
|
|
}
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
UXComponentExtensionsHelper.SetAudioHelper(new UXAuditoHelper(audioSource));
|
|
BindHotKeys();
|
|
}
|
|
|
|
private void OnApplicationQuit()
|
|
{
|
|
UnBindHotKeys();
|
|
}
|
|
|
|
internal void BindHotKeys()
|
|
{
|
|
for (int i = 0; i < hotButtons.Length; i++)
|
|
{
|
|
hotButtons[i].BindHotKey();
|
|
}
|
|
}
|
|
|
|
internal void UnBindHotKeys()
|
|
{
|
|
for (int i = 0; i < hotButtons.Length; i++)
|
|
{
|
|
hotButtons[i].UnBindHotKey();
|
|
}
|
|
}
|
|
}
|