Predective algo
This commit is contained in:
30
Assets/Scripts/Utils/SliderValueText.cs
Normal file
30
Assets/Scripts/Utils/SliderValueText.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(TMP_Text))]
|
||||
public class SliderValueText : MonoBehaviour
|
||||
{
|
||||
public Slider slider;
|
||||
|
||||
|
||||
void OnValidate(){
|
||||
if(slider==null){
|
||||
slider = GetComponentInParent<Slider>();
|
||||
}
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
slider.onValueChanged.AddListener(RefreshText);
|
||||
txt= GetComponent<TMP_Text>();
|
||||
RefreshText(slider.value);
|
||||
|
||||
}
|
||||
TMP_Text txt;
|
||||
|
||||
void RefreshText(float value){
|
||||
txt.text = slider.value.ToString("n3");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Utils/SliderValueText.cs.meta
Normal file
11
Assets/Scripts/Utils/SliderValueText.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffd6249c0d241384ab3caa05bc93e9cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user