I don't know why my script below in unity c# always got null ?
public class WeatherControl : MonoBehaviour {
public GameObject Rain;
public int[] RainTime = new int[]{6,7,8,9,10,18,19,20,21,22,16};
int day;
System.DateTime dates;
// Use this for initialization
void Start () {
dates = System.DateTime.UtcNow;
day = (int) dates.Day;
//day = 16;
Debug.Log ("DAY : " + day);
int posRain = System.Array.FindIndex (RainTime, x => x.Equals(16));
Debug.Log ("POS RAIN : " + posRain);
if (posRain >= 0) {
Rain.SetActive (true);
} else {
Rain.SetActive (false);
}
}
}
my variable int posRain always return -1 Even at array there is value contain it. the variable day contain 16. I put it manually and type 16 too. But always return -1. I don't know why.
I have try this too :
int posRain = System.Array.IndexOf (RainTime, day);
That's always return -1 too.
I have tested it at online C# Tester here : https://csharppad.com/
It works at it return 10.
But in unity c# editor it is different always return -1.
Could someone explain what is going on ?
Thanks
Dennis