Merge branch 'main' into DO-46-게임-씬-보조-기능-추가

This commit is contained in:
Lim0_C 2025-03-26 17:47:13 +09:00
commit ddd12b06fb
3 changed files with 57 additions and 2 deletions

View File

@ -102,7 +102,7 @@ public class AudioManager : Singleton<AudioManager>
public void PlayClickSound()
{
if (sfxAudioSource != null)
if (isPlaySFX && sfxAudioSource != null)
{
sfxAudioSource.PlayOneShot(clickSound, sfxVolume);
}
@ -111,7 +111,7 @@ public class AudioManager : Singleton<AudioManager>
// 닫기 사운드(SFX) 재생
public void PlayCloseSound()
{
if (sfxAudioSource != null)
if (isPlaySFX && sfxAudioSource != null)
{
sfxAudioSource.PlayOneShot(closeSound, sfxVolume);
}

View File

@ -0,0 +1,52 @@
using UnityEngine;
using UnityEngine.UI;
public class SingleInteractableButtonHandler : MonoBehaviour
{
[Tooltip("이 버튼이 한 번만 클릭되도록 제한할지 여부")]
[SerializeField] private bool enableOneTimeClick = true;
private Button _button;
private bool hasBeenClicked = false;
private void Awake()
{
// 버튼 컴포넌트 가져오기
_button = GetComponent<Button>();
if (_button != null && enableOneTimeClick)
{
// 기존 onClick 이벤트를 저장
Button.ButtonClickedEvent originalOnClick = _button.onClick;
_button.onClick = new Button.ButtonClickedEvent();
_button.onClick.AddListener(() =>
{
if (!hasBeenClicked)
{
hasBeenClicked = true;
for (int i = 0; i < originalOnClick.GetPersistentEventCount(); i++)
{
originalOnClick.Invoke();
}
// 버튼 비활성화
_button.interactable = false;
}
});
}
}
// 버튼 상태 리셋
public void ResetButton()
{
hasBeenClicked = false;
if (_button != null)
{
_button.interactable = true;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4330206548604932b038a7007dacf94b
timeCreated: 1742970986