123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- using System.Collections;
- using System.Collections.Generic;
- using TMPro;
- using UnityEngine;
- public class VibrationParameters : MonoBehaviour
- {
- public TMP_InputField input_Amplitude;
- public TMP_InputField input_Frequency;
- public TMP_InputField input_Time;
- private float amplitude;
- private float frequency;
- private float time;
- private const float min = 0f;
- private const float max = 1f;
- private const float max_time = 3.1f;
- private void Start()
- {
- amplitude = 0.5f;
- frequency = 0.5f;
- time = 0.5f;
- input_Amplitude.text = amplitude.ToString();
- input_Frequency.text = frequency.ToString();
- input_Time.text = time.ToString();
- }
- #region[Amplitude]
- public void Plus_Amplitude()
- {
- if (amplitude < max)
- {
- amplitude += 0.01f;
- amplitude = float.Parse(amplitude.ToString("#0.00"));
- input_Amplitude.text = amplitude.ToString();
- }
- }
- public void Plus5_Amplitude()
- {
- if (amplitude < max)
- {
- float temp = amplitude + 0.05f;
- temp = float.Parse(temp.ToString("#0.00"));
- if (temp >= max)
- {
- amplitude = max;
- }
- else
- {
- amplitude = temp;
- }
- input_Amplitude.text = amplitude.ToString();
- }
- }
- public void Minus_Amplitude()
- {
- if (amplitude > min)
- {
- amplitude -= 0.10f;
- amplitude = float.Parse(amplitude.ToString("#0.00"));
- input_Amplitude.text = amplitude.ToString();
- }
- }
- public void Minus5_Amplitude()
- {
- if (amplitude > min)
- {
- float temp = amplitude - 0.05f;
- temp = float.Parse(temp.ToString("#0.00"));
- if (temp <= min)
- {
- amplitude = min;
- }
- else
- {
- amplitude = temp;
- }
- input_Amplitude.text = amplitude.ToString();
- }
- }
- #endregion
- #region[Frequency]
- public void Plus_Frequency()
- {
- if (frequency < max)
- {
- frequency += 0.01f;
- frequency = float.Parse(frequency.ToString("#0.00"));
- input_Frequency.text = frequency.ToString();
- }
- }
- public void Plus5_Frequency()
- {
- if (frequency < max)
- {
- float temp = frequency + 0.05f;
- temp = float.Parse(temp.ToString("#0.00"));
- if (temp >= max)
- {
- frequency = max;
- }
- else
- {
- frequency = temp;
- }
- input_Frequency.text = frequency.ToString();
- }
- }
- public void Minus_Frequency()
- {
- if (frequency > min)
- {
- frequency -= 0.01f;
- frequency = float.Parse(frequency.ToString("#0.00"));
- input_Frequency.text = frequency.ToString();
- }
- }
- public void Minus5_Frequency()
- {
- if (frequency > min)
- {
- float temp = frequency - 0.05f;
- temp = float.Parse(temp.ToString("#0.00"));
- if (temp <= min)
- {
- frequency = min;
- }
- else
- {
- frequency = temp;
- }
- input_Frequency.text = frequency.ToString();
- }
- }
- #endregion
- #region[Time]
- public void Plus_Time()
- {
- if (time < max_time)
- {
- time += 0.01f;
- time = float.Parse(time.ToString("#0.00"));
- input_Time.text = time.ToString();
- }
- }
- public void Plus5_Time()
- {
- if (time < max_time)
- {
- float temp = time + 0.05f;
- temp = float.Parse(temp.ToString("#0.00"));
- if (temp >= max_time)
- {
- time = max_time;
- }
- else
- {
- time = temp;
- }
- input_Time.text = time.ToString();
- }
- }
- public void Minus_Time()
- {
- if (time > min)
- {
- time -= 0.01f;
- time = float.Parse(time.ToString("#0.00"));
- input_Time.text = time.ToString();
- }
- }
- public void Minus5_Time()
- {
- if (time > min)
- {
- float temp = time - 0.05f;
- temp = float.Parse(temp.ToString("#0.00"));
- if (temp <= min)
- {
- time = min;
- }
- else
- {
- time = temp;
- }
- input_Time.text = time.ToString();
- }
- }
- #endregion
- }
|