您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
38 行
753 B
38 行
753 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class UISliderBehaviour : MonoBehaviour
|
|
{
|
|
|
|
[Header("UI References")]
|
|
public Slider slider;
|
|
public UITextBehaviour textSliderDisplay;
|
|
|
|
public void SetupDisplay(float totalValue)
|
|
{
|
|
SetMaxValue(totalValue);
|
|
}
|
|
|
|
void SetMaxValue(float newValue)
|
|
{
|
|
slider.maxValue = newValue;
|
|
}
|
|
|
|
public void SetCurrentValue(float newValue)
|
|
{
|
|
slider.value = newValue;
|
|
SetTextDisplay();
|
|
}
|
|
|
|
void SetTextDisplay()
|
|
{
|
|
if(textSliderDisplay != null)
|
|
{
|
|
textSliderDisplay.SetText(slider.value + "/" + slider.maxValue);
|
|
}
|
|
}
|
|
|
|
}
|