Newer
Older
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class BlockObjectClass : MonoBehaviour
{
public float InhalePeriod { get; private set; }
public float ExhalePeriod { get; private set; }
public float MaxRuntime { get; private set; }
TMP_InputField inhalePeriodTextInput;
TMP_InputField exhalePeriodTextInput;
TMP_InputField runtimeTextInput;
void Awake()
{
string name;
GameObject go;
Transform[] transforms = this.GetComponentsInChildren<Transform>();
foreach (var transform in transforms)
{
go = transform.gameObject;
name = go.name;
if (name == "Inhale")
{
inhalePeriodTextInput = go.GetComponent<TMP_InputField>();
SetInhalePeriod();
}
else if (name == "Exhale")
{
exhalePeriodTextInput = go.GetComponent<TMP_InputField>();
SetExhalePeriod();
}
else if (name == "Runtime")
{
SetRuntime();
}
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
if (inhalePeriod == -1)
{
InhalePeriod = (float)Convert.ToDouble(inhalePeriodTextInput.text);
}
else
{
InhalePeriod = inhalePeriod;
}
if (exhalePeriod == -1)
{
ExhalePeriod = (float)Convert.ToDouble(exhalePeriodTextInput.text);
}
else
{
ExhalePeriod = exhalePeriod;
}
if (runtimeInput == -1)
{
MaxRuntime = (float)Convert.ToDouble(runtimeTextInput.text) * 60;
}
else
{
MaxRuntime = runtimeInput;
}