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 }