DEG-86 [Feat] 팝업 및 설정 UI 스크립트 추가
This commit is contained in:
parent
c436a73f5c
commit
a77e1ab6e2
BIN
Assets/LYM/Scenes/MainUI.unity
(Stored with Git LFS)
BIN
Assets/LYM/Scenes/MainUI.unity
(Stored with Git LFS)
Binary file not shown.
@ -5,14 +5,18 @@ using UnityEngine.UI;
|
||||
|
||||
public class MainUIPanelController : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private GameObject settingsPanelPrefab;
|
||||
[SerializeField] private GameObject popupPanelPrefab;
|
||||
|
||||
public void OnClickStartButton()
|
||||
{
|
||||
|
||||
var popupPanel = Instantiate(popupPanelPrefab, transform);
|
||||
popupPanel.GetComponent<PopupPanelController>().Show("This is PopupPanel!!", () => {Debug.Log("Confirmed");});
|
||||
}
|
||||
|
||||
public void OnClickSettingsButton()
|
||||
{
|
||||
|
||||
var settingsPanel = Instantiate(settingsPanelPrefab, transform);
|
||||
settingsPanel.GetComponent<SettingsPanelController>().Show();
|
||||
}
|
||||
}
|
||||
|
@ -26,5 +26,6 @@ public class PanelController : MonoBehaviour
|
||||
{
|
||||
if (_canvasGroup == null) return;
|
||||
_canvasGroup.alpha = 0;
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -8,26 +9,18 @@ public class PopupPanelController : PanelController
|
||||
{
|
||||
[SerializeField] private GameObject confirmButton;
|
||||
[SerializeField] private GameObject contradictButton;
|
||||
[SerializeField] private TMP_Text popupText;
|
||||
|
||||
public delegate void OnConfirmDelegate();
|
||||
private OnConfirmDelegate _onConfirmDelegate;
|
||||
public delegate void OnContradictDelegate();
|
||||
private OnContradictDelegate _onContradictDelegate;
|
||||
private void Start()
|
||||
{
|
||||
Show(false, "수면에 들 시간입니다.", () => {});
|
||||
}
|
||||
|
||||
public void Show(bool isNeed2Contradict, string message, OnConfirmDelegate onConfirm)
|
||||
public void Show(string message, OnConfirmDelegate onConfirm, OnContradictDelegate onContradict = null)
|
||||
{
|
||||
confirmButton.SetActive(isNeed2Contradict);
|
||||
_onConfirmDelegate = onConfirm;
|
||||
base.Show();
|
||||
}
|
||||
|
||||
public void Show(bool isNeed2Contradict, string message, OnConfirmDelegate onConfirm, OnContradictDelegate onContradict)
|
||||
{
|
||||
confirmButton.SetActive(isNeed2Contradict);
|
||||
bool isNeed2Contradict = onContradict != null;
|
||||
contradictButton.SetActive(isNeed2Contradict);
|
||||
popupText.text = message;
|
||||
_onConfirmDelegate = onConfirm;
|
||||
_onContradictDelegate = onContradict;
|
||||
base.Show();
|
||||
|
@ -1,18 +1,66 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsPanelController : MonoBehaviour
|
||||
public class SettingsPanelController : PanelController
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
|
||||
[SerializeField] private SliderButton sfxSliderButton;
|
||||
[SerializeField] private SliderButton bgmSliderButton;
|
||||
[SerializeField] private Slider sfxSlider;
|
||||
[SerializeField] private Slider bgmSlider;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
InitSettings();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void InitSettings()
|
||||
{
|
||||
|
||||
//todo:저장된 데이터를 가져오게 해야함
|
||||
var sfxIsActive = true;
|
||||
var bgmIsActive = true;
|
||||
sfxSliderButton.Init(sfxIsActive);
|
||||
bgmSliderButton.Init(bgmIsActive);
|
||||
//todo:저장된 데이터를 가져오게 해야함
|
||||
var sfxSliderValue = 1f;
|
||||
var bgmSliderValue = 1f;
|
||||
sfxSlider.value = sfxSliderValue;
|
||||
bgmSlider.value = bgmSliderValue;
|
||||
Show();
|
||||
}
|
||||
|
||||
//버튼 클릭 시 마다 호출
|
||||
public void SFXSliderButtonClicked()
|
||||
{
|
||||
sfxSliderButton.OnClicked();
|
||||
//todo: sfxSliderButton.IsActive를 기준으로 뮤트 여부 확인 및 뮤트 적용
|
||||
}
|
||||
|
||||
public void BGMSliderButtonClicked()
|
||||
{
|
||||
bgmSliderButton.OnClicked();
|
||||
//todo: sfxSliderButton.IsActive를 기준으로 뮤트 여부 확인 및 뮤트 적용
|
||||
}
|
||||
|
||||
//슬라이더 변경 시 마다 호출
|
||||
public void OnSFXSliderValueChanged(float value)
|
||||
{
|
||||
//todo: 소리 볼륨 조절
|
||||
Debug.Log("sfx changed value" + value);
|
||||
}
|
||||
|
||||
public void OnBGMSliderValueChanged(float value)
|
||||
{
|
||||
//todo: 소리 볼륨 조절
|
||||
Debug.Log("bgm changed value" + value);
|
||||
}
|
||||
|
||||
public void OnCloseButtonClicked()
|
||||
{
|
||||
//todo: 설정 저장 필요
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -15,12 +16,13 @@ public class SliderButton : MonoBehaviour
|
||||
private Color32 _offColor = new Color32(125, 125, 125, 255);
|
||||
private Color32 _onColor = new Color32(70, 255, 90, 255);
|
||||
|
||||
|
||||
public void Init(bool isActive)
|
||||
{
|
||||
IsActive = isActive;
|
||||
var xLocation = IsActive ? _onXLocation : _offXLocation;
|
||||
var color = IsActive ? _onColor : _offColor;
|
||||
handle.transform.localPosition = new Vector3(xLocation, handle.transform.localPosition.y, 0);
|
||||
backgroundImage.color = color;
|
||||
}
|
||||
|
||||
public void OnClicked()
|
||||
@ -28,11 +30,12 @@ public class SliderButton : MonoBehaviour
|
||||
if (IsActive)
|
||||
{
|
||||
handle.transform.DOLocalMoveX(_offXLocation, 0.2f);
|
||||
backgroundImage.DOColor()
|
||||
backgroundImage.DOColor(_offColor, 0.2f);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
handle.transform.DOLocalMoveX(_onXLocation, 0.2f);
|
||||
handle.transform.DOLocalMoveX(_onXLocation, 0.2f);
|
||||
backgroundImage.DOColor(_onColor, 0.2f);
|
||||
}
|
||||
IsActive = !IsActive;
|
||||
}
|
||||
|
BIN
Assets/LYM/UIPrefabs/MainUIPanel.prefab
(Stored with Git LFS)
BIN
Assets/LYM/UIPrefabs/MainUIPanel.prefab
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/LYM/UIPrefabs/PopupPanel.prefab
(Stored with Git LFS)
BIN
Assets/LYM/UIPrefabs/PopupPanel.prefab
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/LYM/UIPrefabs/SettingsPanel.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/LYM/UIPrefabs/SettingsPanel.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
7
Assets/LYM/UIPrefabs/SettingsPanel.prefab.meta
Normal file
7
Assets/LYM/UIPrefabs/SettingsPanel.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fe584d3180d4924e97a2084be3b454e
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user