暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Noodle_Auto.cs 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. public class Noodle_Auto : MonoBehaviour
  6. {
  7. [SerializeField] TextMeshProUGUI MaxValue;
  8. [SerializeField] TextMeshProUGUI 數值來源;
  9. public string 來源類型;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. try{
  18. if(來源類型=="V" && 來源類型=="I"){
  19. float data1 = float.Parse(數值來源.text.Substring(0,數值來源.text.Length-2));
  20. float data2,data3;
  21. if(data1 >= (float.Parse(MaxValue.text)/2)){
  22. data2 = data1-(float.Parse(MaxValue.text)/2);
  23. data3 = (-90f*data2)/(float.Parse(MaxValue.text)/2);
  24. }else{
  25. data2 = (float.Parse(MaxValue.text)/2)-data1;
  26. data3 = (90f*data2)/(float.Parse(MaxValue.text)/2);
  27. }
  28. transform.rotation = Quaternion.Euler (0f, 0f, data3);
  29. }else{
  30. float data1 = float.Parse(數值來源.text.Substring(0,數值來源.text.Length-2));
  31. float data2,data3;
  32. if(data1 >= (float.Parse(MaxValue.text)/2)){
  33. data2 = data1-(float.Parse(MaxValue.text)/2);
  34. data3 = (-90f*data2)/(float.Parse(MaxValue.text)/2);
  35. }else{
  36. data2 = (float.Parse(MaxValue.text)/2)-data1;
  37. data3 = (90f*data2)/(float.Parse(MaxValue.text)/2);
  38. }
  39. transform.rotation = Quaternion.Euler (0f, 0f, data3);
  40. }
  41. }catch{
  42. }
  43. }
  44. }