컴퓨터 ui 완성
This commit is contained in:
46
Assets/02_Scripts/UI/HeartAffectionUI.cs
Normal file
46
Assets/02_Scripts/UI/HeartAffectionUI.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class HeartAffectionUI : MonoBehaviour
|
||||
{
|
||||
[Header("채워지는 하트 10개")]
|
||||
public Image[] fillHearts;
|
||||
|
||||
[Header("퍼센트 텍스트")]
|
||||
public TMP_Text percentText;
|
||||
|
||||
[Header("호감도")]
|
||||
[Range(0, 100)]
|
||||
public int affectionPercent = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetAffection(affectionPercent);
|
||||
}
|
||||
|
||||
public void SetAffection(int percent)
|
||||
{
|
||||
affectionPercent = Mathf.Clamp(percent, 0, 100);
|
||||
|
||||
// 11% = 1.1개 하트
|
||||
// 45% = 4.5개 하트
|
||||
// 78% = 7.8개 하트
|
||||
float heartValue = affectionPercent / 10f;
|
||||
|
||||
for (int i = 0; i < fillHearts.Length; i++)
|
||||
{
|
||||
fillHearts[i].fillAmount = Mathf.Clamp01(heartValue - i);
|
||||
}
|
||||
|
||||
if (percentText != null)
|
||||
{
|
||||
percentText.text = affectionPercent + "%";
|
||||
}
|
||||
}
|
||||
|
||||
public void AddAffection(int amount)
|
||||
{
|
||||
SetAffection(affectionPercent + amount);
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/HeartAffectionUI.cs.meta
Normal file
2
Assets/02_Scripts/UI/HeartAffectionUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c24b2d88eab370744b5aa15143ad93d7
|
||||
41
Assets/02_Scripts/UI/MainProgressUI.cs
Normal file
41
Assets/02_Scripts/UI/MainProgressUI.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class MainProgressUI : MonoBehaviour
|
||||
{
|
||||
[Header("진행도 채움 이미지")]
|
||||
public Image progressFill;
|
||||
|
||||
[Header("퍼센트 텍스트")]
|
||||
public TMP_Text percentText;
|
||||
|
||||
[Header("메인 진행도")]
|
||||
[Range(0, 100)]
|
||||
public int progressPercent = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetProgress(progressPercent);
|
||||
}
|
||||
|
||||
public void SetProgress(int percent)
|
||||
{
|
||||
progressPercent = Mathf.Clamp(percent, 0, 100);
|
||||
|
||||
if (progressFill != null)
|
||||
{
|
||||
progressFill.fillAmount = progressPercent / 100f;
|
||||
}
|
||||
|
||||
if (percentText != null)
|
||||
{
|
||||
percentText.text = progressPercent + "%";
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProgress(int amount)
|
||||
{
|
||||
SetProgress(progressPercent + amount);
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/MainProgressUI.cs.meta
Normal file
2
Assets/02_Scripts/UI/MainProgressUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 035493732111afa4e907adcfcbbabb3c
|
||||
Reference in New Issue
Block a user