세팅 패널 제작
This commit is contained in:
parent
c36ae42494
commit
cadb3a7c99
1379
Assets/Prefab/Setting Panel.prefab
Normal file
1379
Assets/Prefab/Setting Panel.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefab/Setting Panel.prefab.meta
Normal file
7
Assets/Prefab/Setting Panel.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea820246b5075c54d9f614291ca41c5d
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -352,7 +352,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 681.2}
|
||||
m_AnchoredPosition: {x: 0, y: 680}
|
||||
m_SizeDelta: {x: 300, y: 300}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &615795274
|
||||
@ -642,7 +642,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 681.2}
|
||||
m_AnchoredPosition: {x: 0, y: 200}
|
||||
m_SizeDelta: {x: 300, y: 300}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1443666893
|
||||
@ -703,7 +703,7 @@ MonoBehaviour:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1443666893}
|
||||
m_TargetAssemblyTypeName: ClickGenButton, Assembly-CSharp
|
||||
m_MethodName: ClickConfirmPanel
|
||||
m_MethodName: ClickSettingsPanel
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@ -733,8 +733,8 @@ MonoBehaviour:
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_Sprite: {fileID: 21300000, guid: 17abb32a02ecec341b8b2396c7830408, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
@ -796,6 +796,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
confirmPanel: {fileID: 8145365568262946399, guid: 76f1fe6b5243faf4f9b8caee7312d336, type: 3}
|
||||
settingsPanel: {fileID: 2861881646994438329, guid: ea820246b5075c54d9f614291ca41c5d, type: 3}
|
||||
_canvas: {fileID: 103910628}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
|
@ -4,13 +4,29 @@ using UnityEngine;
|
||||
|
||||
public class ClickGenButton : MonoBehaviour
|
||||
{
|
||||
|
||||
//확인 패널 여는 함수 여는 함수
|
||||
public void ClickConfirmPanel()
|
||||
{
|
||||
GameManager.Instance.OpenConfirmPanel("Click Gen Button",ClickConfirmButton);
|
||||
}
|
||||
|
||||
void ClickConfirmButton()
|
||||
{
|
||||
Debug.Log("Click Confirm Button");
|
||||
}
|
||||
|
||||
//세팅 패널 여는 함수 여는 함수
|
||||
public void ClickSettingsPanel()
|
||||
{
|
||||
GameManager.Instance.OpenSettingsPanel();
|
||||
}
|
||||
|
||||
//스크롤 패널 여는 함수 여는 함수
|
||||
|
||||
|
||||
//결과 패널 여는 함수 여는 함수
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using UnityEngine;
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject confirmPanel;
|
||||
[SerializeField] private GameObject settingsPanel;
|
||||
|
||||
public Canvas _canvas;
|
||||
|
||||
@ -27,6 +28,8 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//확인 패널 여는 함수
|
||||
public void OpenConfirmPanel(string message, ConfirmPanelController.OnConfirmButtonClick onConfirmButtonClick)
|
||||
{
|
||||
if (_canvas != null)
|
||||
@ -36,4 +39,22 @@ public class GameManager : MonoBehaviour
|
||||
.Show(message, onConfirmButtonClick);
|
||||
}
|
||||
}
|
||||
|
||||
//세팅 패널 여는 함수
|
||||
public void OpenSettingsPanel()
|
||||
{
|
||||
if (_canvas != null)
|
||||
{
|
||||
var settingsPanelObject = Instantiate(settingsPanel, _canvas.transform);
|
||||
settingsPanelObject.GetComponent<PanelController>().Show();
|
||||
}
|
||||
}
|
||||
|
||||
//스크롤 패널 여는 함수
|
||||
|
||||
|
||||
//결과 패널 여는 함수
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
38
Assets/Script/UI_Panel/SettingPanelController.cs
Normal file
38
Assets/Script/UI_Panel/SettingPanelController.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsPanelController : PanelController
|
||||
{
|
||||
[SerializeField] private Button sfxSwitch;
|
||||
[SerializeField] private Button bgmSwitch;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//스위치 컨트롤러 상태 변경 이벤트 연결
|
||||
sfxSwitch.GetComponent<SwitchController>().OnSwitchChanged += (OnSFXToggleValueChanged);
|
||||
bgmSwitch.GetComponent<SwitchController>().OnSwitchChanged += (OnBGMToggleValueChanged);
|
||||
}
|
||||
|
||||
// SFX On/Off시 호출되는 함수
|
||||
public void OnSFXToggleValueChanged(bool value)
|
||||
{
|
||||
Debug.Log("SFX : "+ value);
|
||||
}
|
||||
|
||||
|
||||
// BGM On/Off시 호출되는 함수
|
||||
public void OnBGMToggleValueChanged(bool value)
|
||||
{
|
||||
Debug.Log("BGM : "+ value);
|
||||
}
|
||||
|
||||
|
||||
// X 버튼 클릭시 호출되는 함수
|
||||
public void OnClickCloseButton()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
11
Assets/Script/UI_Panel/SettingPanelController.cs.meta
Normal file
11
Assets/Script/UI_Panel/SettingPanelController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71858c2af530df44492b05dd5c046d48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
71
Assets/Script/UI_Panel/SwitchController.cs
Normal file
71
Assets/Script/UI_Panel/SwitchController.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
[RequireComponent(typeof(Image))]
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class SwitchController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image handleImage;
|
||||
[SerializeField] private AudioClip clickSound;
|
||||
|
||||
//스위치에 상태 변경 시 호출할 콜백 함수
|
||||
public delegate void OnSwitchChangedDelegate(bool isOn);
|
||||
public OnSwitchChangedDelegate OnSwitchChanged;
|
||||
|
||||
private static readonly Color32 OnColor = new Color32(242, 68, 149, 255);
|
||||
private static readonly Color32 OffColor = new Color32(70, 93, 117, 255);
|
||||
|
||||
private RectTransform _handleRectTransform;
|
||||
private Image _backgroundImage;
|
||||
private AudioSource _audioSource;
|
||||
|
||||
private bool _isOn;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_handleRectTransform = handleImage.GetComponent<RectTransform>();
|
||||
_backgroundImage = GetComponent<Image>();
|
||||
_audioSource = GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//초기 상태는 false
|
||||
_handleRectTransform.anchoredPosition = new Vector2(-14, 0);
|
||||
_backgroundImage.color = OffColor;
|
||||
_isOn = false;
|
||||
}
|
||||
|
||||
//스위치 상태 변경 함수
|
||||
private void SetOn(bool isOn)
|
||||
{
|
||||
|
||||
if (isOn)
|
||||
{
|
||||
_handleRectTransform.DOAnchorPosX(14, 0.2f);
|
||||
_backgroundImage.DOBlendableColor(OnColor, 0.2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_handleRectTransform.DOAnchorPosX(-14, 0.2f);
|
||||
_backgroundImage.DOBlendableColor(OffColor, 0.2f);
|
||||
}
|
||||
|
||||
// 효과음 재생
|
||||
if (clickSound != null)
|
||||
_audioSource.PlayOneShot(clickSound);
|
||||
|
||||
//이벤트 호출
|
||||
OnSwitchChanged?.Invoke(isOn);
|
||||
_isOn = isOn;
|
||||
}
|
||||
|
||||
public void OnClickSwitch()
|
||||
{
|
||||
SetOn(!_isOn);
|
||||
}
|
||||
}
|
11
Assets/Script/UI_Panel/SwitchController.cs.meta
Normal file
11
Assets/Script/UI_Panel/SwitchController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb609268e5d7ff14a8a5d4ad7c0f8ba3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Sounds.meta
Normal file
8
Assets/Sounds.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a716234a0e4752148a60610ac1cc1185
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/ClickSwitch.wav
Normal file
BIN
Assets/Sounds/ClickSwitch.wav
Normal file
Binary file not shown.
23
Assets/Sounds/ClickSwitch.wav.meta
Normal file
23
Assets/Sounds/ClickSwitch.wav.meta
Normal file
@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6296b07572c34d4439bb8bb660025449
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 7
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user