30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
|
|||
|
|
[RequireComponent(typeof(Button))]
|
|||
|
|
public class ButtonEventReceiver : MonoBehaviour {
|
|||
|
|
// HACK 次のアプリでは削除する
|
|||
|
|
public string onClickPlaySEFilename;
|
|||
|
|
[SerializeField]
|
|||
|
|
private string[] randomPlaySEFilenames = default;
|
|||
|
|
[SerializeField]
|
|||
|
|
private string[] randomPlayVoiceFilenames = default;
|
|||
|
|
[SerializeField]
|
|||
|
|
private VibrationType vibrationType = default;
|
|||
|
|
|
|||
|
|
void Awake(){
|
|||
|
|
GetComponent<Button>().onClick.AddListener(() => {
|
|||
|
|
if(randomPlaySEFilenames.Length > 0){
|
|||
|
|
SoundManager.Instance.PlaySE(string.Format("Sounds/SE/{0}", randomPlaySEFilenames.RandomChoose()));
|
|||
|
|
}
|
|||
|
|
if(randomPlayVoiceFilenames.Length > 0){
|
|||
|
|
SoundManager.Instance.PlayVoice(string.Format("Sounds/VOICE/{0}", randomPlayVoiceFilenames.RandomChoose()));
|
|||
|
|
}
|
|||
|
|
if(onClickPlaySEFilename.Length > 0){
|
|||
|
|
SoundManager.Instance.PlaySE(string.Format("Sounds/SE/{0}", onClickPlaySEFilename));
|
|||
|
|
}
|
|||
|
|
VibrationManager.Instance.PlayVibration(vibrationType);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|