How do I detect if game is in play or edit mode?

I want it so that when the object is in play mode, it will have a different material compared to the one in edit mode. How can I achieve that?

The Application class has a few items that might be of interest, Application.isPlaying, and Application.isEditor. Of course, you could just change the material from the editor one to the play one in Start(), too.