I'm trying to take the data I have in string format that is already being read out in my unity console into a float so I can put it through an if statement. However, unity is telling me I can't use "<" on a double or bool value. I'm not sure what changes I would need to make to get the if statement to read the value (possibly another data type?). Any help would be greatly appreciated!!!
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class HeaterRead : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
using (var reader = new StreamReader(@"C:\Users\labom\Documents\Work Files\Heater_Main_Output.csv"))
{
List<string> listA = new List<string>();
List<string> listB = new List<string>();
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(',');
listA.Add(values[2]);
listB.Add(values[3]);
Debug.Log(values[2].ToString() + " " + values[3].ToString());
line = reader.ReadLine();
}
float TempVal = float.Parse(listB[3]);
if (TempVal < 300)
{
gameObject.GetComponent<Renderer>().material.color = new Color(1, 1, 1, 1);
}
if (300 <= TempVal < 308.4)
{
gameObject.GetComponent<Renderer>().material.color = new Color(0, 0, 0, 1);
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire