2026-03-22 스왑버튼 그룹구현
This commit is contained in:
8
Assets/02_Scripts/UI/Menu/Buttons.meta
Normal file
8
Assets/02_Scripts/UI/Menu/Buttons.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47a94c1e8d71a2a46a650da8ae5d483c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,53 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(Image))]
|
||||
public class SwapButton : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public Image TargetImage;
|
||||
|
||||
public Sprite ASprite;
|
||||
public UnityEvent ClickEventA = new UnityEvent();
|
||||
|
||||
public Sprite BSprite;
|
||||
public UnityEvent ClickEventB = new UnityEvent();
|
||||
|
||||
[SerializeField] private bool _trueA_FalseB = true;
|
||||
|
||||
public bool TrueA_FalseB
|
||||
{
|
||||
get => _trueA_FalseB;
|
||||
set
|
||||
{
|
||||
_trueA_FalseB = value;
|
||||
UpdateVisual(); // 값이 바뀔 때마다 자동으로 실행!
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
TargetImage = GetComponent<Image>();
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
TrueA_FalseB = !TrueA_FalseB;
|
||||
|
||||
if (TrueA_FalseB)
|
||||
ClickEventA?.Invoke();
|
||||
else
|
||||
ClickEventB?.Invoke();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
UpdateVisual();
|
||||
}
|
||||
public void UpdateVisual()
|
||||
{
|
||||
if (TargetImage == null) return;
|
||||
TargetImage.sprite = _trueA_FalseB ? ASprite : BSprite;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7742f072d8001394ca9c68f41507c667
|
||||
Reference in New Issue
Block a user