As an exercise I have made 7 buttons in Unity. Each day of the week corresponds with a button (button 0 = sunday, button 1 = monday, …).
The intention is that you have to click on the button which corresponds with the actual day.
For example, today it’s sunday. When you click on button 0, you will hear an audioclip “Good”.
But if you click on button 1, you will hear “Not good”.
If you do this tomorrow, you will hear “Not good” if you hit button 0 and hear “Good” if you hit button 1.
So you will need the actual day from the computer.
I’m a beginner with javascript and I’m trying to realise this with the next script:
var soundGood : AudioClip;
var soundNotGood : AudioClip;
var d = new Date();
var curr_day = d.getDay();
function OnMouseUp()
{
if (curr_day == 0)
{
audio.PlayOneShot(soundGood);
}
else if (curr_day == 1 || curr_day == 2 || curr_day == 3 || curr_day == 4 || curr_day == 5 || curr_day == 6)
{
audio.PlayOneShot(soundNotGood);
}
}
This doesn’t work.
I have the next error: MissingMethodException: Method not found: ‘System.DateTime.getDay’.
I think I overlook something but I have no idea what. What do I have to do to make it work?