[ANSWERD] Do something when it is the correct date

Hi!

I am trying to make a game and I would like to add as easter eggs that the player gets diffrent skins when it is like Halloween or christams. So for example, when it is 31 October (Hallowee), my player will get a custom texture and my music will change. How do I do something in the style with this?

Thanks

How about checking [System.Datetime.Today][1]? [1]: http://msdn.microsoft.com/en-us/library/system.datetime.today(v=vs.110).aspx

I don't know how to code in C#. I only know how to code in JavaScript

You can import the System class into your javascript class. [This has been answered before][1] [1]: http://answers.unity3d.com/questions/9862/read-time-and-date.html

1 Answer

1

var thisDate = System.DateTime.Today;
var halloweenDate = System.DateTime(2013, 10, 31, 0, 0, 0);

if(thisDate.Date.Equals(halloweenDate)) {
	Debug.Log("Happy Halloween!");
}

Thank you so much! :D Also, how do I do so I can make the year doesn't matter?

For that, just compare the Month and Day components: var thisDate = System.DateTime.Today; if(thisDate.Month == 10 && thisDate.Day == 31) { Debug.Log("Today is the 31st of October, in any year"); }

Thanks! :D

No problem. Please mark as the answer to keep the board tidy. Thanks!

@fafase - Please do not close questions that have not yet had answers accepted. It makes the board very untidy!