123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using DG.Tweening;
- using System.Collections;
- using System.Collections.Generic;
- using TMPro;
- using UnityEngine;
- public class TestUiSlider : MonoBehaviour
- {
- public Transform parten;
- public Transform left;
- public Transform right;
- public TextMeshProUGUI txt_left;
- public TextMeshProUGUI txt_Right;
- // Start is called before the first frame update
- void Start()
- {
- }
- public void Leftinit(double value, double upper, double lower = 0)
- {
- if (left == null)
- {
- return;
- }
- if (txt_left != null)
- {
- txt_left.text = value.ToString();
- }
- if (value > upper )
- {
- value = upper;
- //Êý¾ÝÒì³£
- }
- if (value < lower)
- {
- value = lower;
- }
- float date = (float)(value - lower);
- float data = (float)(upper - lower);
- float height = parten.GetComponent<RectTransform>().rect.height;
- float y = (float)(date / data) * height;
- left.DOLocalMoveY(y, 0.5f);
- }
- public void Rightinit(double value, double upper,double lower = 0)
- {
- if (right == null )
- {
- return;
- }
- if (txt_Right != null)
- {
- txt_Right.text = value.ToString();
- }
- if (value>upper)
- {
- value = upper;
- //Êý¾ÝÒì³£
- }
- if (value < lower)
- {
- value = lower;
- }
- float date =(float) (value - lower);
- float data = (float)(upper - lower);
- float height = parten.GetComponent<RectTransform>().rect.height;
- float y = (float)(date / data) * height;
- right.DOLocalMoveY(y, 0.5f);
- }
- }
|