説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Bar_Auto.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. using UnityEngine.UI;
  6. using System;
  7. public class Bar_Auto : MonoBehaviour
  8. {
  9. [SerializeField] TextMeshProUGUI 數值來源;
  10. public string 來源類型;
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14. }
  15. // Update is called once per frame
  16. void Update()
  17. {
  18. try{
  19. if(來源類型=="V" || 來源類型=="I"){
  20. GetComponent<Slider>().value=float.Parse(數值來源.text[..^2]);
  21. }else if(來源類型=="P"){
  22. GetComponent<Slider>().value=float.Parse(數值來源.text[..^3]);
  23. }else if(來源類型=="Cos主"){
  24. GetComponent<Slider>().value=Main.Global.功率因素數值;
  25. }else if(來源類型=="Cos副"){
  26. GetComponent<Slider>().value=Main.Global.副功率因素數值;
  27. }else if(來源類型=="Cos詳"){
  28. GetComponent<Slider>().value=Main.Global.詳細功率因素數值;
  29. }else if(來源類型=="時間"){
  30. GetComponent<Slider>().value=float.Parse(數值來源.text);
  31. }else{
  32. GetComponent<Slider>().value=float.Parse(數值來源.text[..^4]);
  33. }
  34. }catch(Exception e){
  35. Debug.Log(e.ToString());
  36. }
  37. }
  38. }