12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- using UnityEngine.UI;
- using System;
-
- public class Bar_Auto : MonoBehaviour
- {
- [SerializeField] TextMeshProUGUI 數值來源;
- public string 來源類型;
- // Start is called before the first frame update
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
- try{
- if(來源類型=="V" || 來源類型=="I"){
- GetComponent<Slider>().value=float.Parse(數值來源.text[..^2]);
- }else if(來源類型=="P"){
- GetComponent<Slider>().value=float.Parse(數值來源.text[..^3]);
- }else if(來源類型=="Cos主"){
- GetComponent<Slider>().value=Main.Global.功率因素數值;
- }else if(來源類型=="Cos副"){
- GetComponent<Slider>().value=Main.Global.副功率因素數值;
- }else if(來源類型=="Cos詳"){
- GetComponent<Slider>().value=Main.Global.詳細功率因素數值;
- }else if(來源類型=="時間"){
- GetComponent<Slider>().value=float.Parse(數值來源.text);
- }else{
- GetComponent<Slider>().value=float.Parse(數值來源.text[..^4]);
- }
- }catch(Exception e){
-
- Debug.Log(e.ToString());
- }
-
- }
- }
|