Button Click Sound Added

This commit is contained in:
2022-02-26 20:09:12 +03:00
parent 5444ba8f1c
commit 9ccfb47c8d
8 changed files with 91 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ namespace UI
public void OnPointerUp(PointerEventData eventData)
{
text.transform.localPosition = initialTextPosition;
UIManager.Instance.PlayClickSound();
}
private void Start()

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using Pausable;
using UnityEngine;
@@ -8,8 +9,10 @@ namespace UI
{
private static UIManager _instance = null;
public static UIManager Instance => _instance;
private Dictionary<string, Canvas> canvases = null;
public Pauser Pauser { get; private set; } = null;
private Dictionary<string, Canvas> canvases = null;
private AudioSource audioSource = null;
private void Awake()
{
@@ -20,7 +23,11 @@ namespace UI
Destroy(this);
}
private void Start() => Pauser = gameObject.AddComponent<Pauser>();
private void Start()
{
Pauser = gameObject.AddComponent<Pauser>();
audioSource = gameObject.GetComponent<AudioSource>();
}
public void SwitchToCanvas(string canvasName)
{
@@ -54,5 +61,7 @@ namespace UI
canvases.Add(child.name, child.GetComponent<Canvas>());
}
}
public void PlayClickSound() => audioSource.Play();
}
}