123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
-
- public class Noodle_Auto : MonoBehaviour
- {
- [SerializeField] TextMeshProUGUI MaxValue;
- [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"){
- float data1 = float.Parse(數值來源.text.Substring(0,數值來源.text.Length-2));
- float data2,data3;
-
- if(data1 >= (float.Parse(MaxValue.text)/2)){
- data2 = data1-(float.Parse(MaxValue.text)/2);
- data3 = (-90f*data2)/(float.Parse(MaxValue.text)/2);
- }else{
- data2 = (float.Parse(MaxValue.text)/2)-data1;
- data3 = (90f*data2)/(float.Parse(MaxValue.text)/2);
- }
- transform.rotation = Quaternion.Euler (0f, 0f, data3);
- }else{
- float data1 = float.Parse(數值來源.text.Substring(0,數值來源.text.Length-2));
- float data2,data3;
-
- if(data1 >= (float.Parse(MaxValue.text)/2)){
- data2 = data1-(float.Parse(MaxValue.text)/2);
- data3 = (-90f*data2)/(float.Parse(MaxValue.text)/2);
- }else{
- data2 = (float.Parse(MaxValue.text)/2)-data1;
- data3 = (90f*data2)/(float.Parse(MaxValue.text)/2);
- }
- transform.rotation = Quaternion.Euler (0f, 0f, data3);
- }
-
-
- }catch{
- }
- }
- }
|