@ 버튼 누르면 HP가 1초씩 계속 줄어들기
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
[SerializeField] Slider slider;
bool isClick = false;
private void Update()
{
if(isClick)
{
slider.value -= Time.deltaTime;
}
}
public void Button()
{
isClick = true;
}
}
@ 도트 데미지 구현하기 (1초마다 체력 감소)
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
[SerializeField] Slider slider;
bool isClick = false;
float dotTime = 1f;
float currentDotTime = 0f;
private void Update()
{
if(isClick)
{
currentDotTime -= Time.deltaTime;
if(currentDotTime < 0 )
{
slider.value -= Time.deltaTime;
if (currentDotTime <= -1f)
{
currentDotTime = dotTime;
}
}
}
}
public void Button()
{
isClick = true;
}
}
- Background : 채워지지 않은 부분(빨간색)
- Fill : 채워지는 부분 (초록색)
- Fill의 Left Right 부분을 조절하면 체력칸을 정확하게 표시 가능.
카메라 우선순위, 오버레이, 겹치기 (0) | 2024.07.01 |
---|---|
인풋 필드 UI (0) | 2024.06.28 |
UI, TextMeshPro(한글폰트 보이는 법), 스킬 쿨타임 (0) | 2024.06.28 |
파티클 시스템 (0) | 2024.06.27 |
애니메이터 (0) | 2024.06.26 |