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().value=float.Parse(數值來源.text[..^2]); }else if(來源類型=="P"){ GetComponent().value=float.Parse(數值來源.text[..^3]); }else if(來源類型=="Cos主"){ GetComponent().value=Main.Global.功率因素數值; }else if(來源類型=="Cos副"){ GetComponent().value=Main.Global.副功率因素數值; }else if(來源類型=="Cos詳"){ GetComponent().value=Main.Global.詳細功率因素數值; }else if(來源類型=="時間"){ GetComponent().value=float.Parse(數值來源.text); }else{ GetComponent().value=float.Parse(數值來源.text[..^4]); } }catch(Exception e){ Debug.Log(e.ToString()); } } }