UNITY_WEBPLAYER in Editor

If I put the following in a game object script, both will appear in the console when previewing with the Play button in the Editor.

#if UNITY_EDITOR
    Debug.Log("Unity Editor");
#endif

#if UNITY_WEBPLAYER
    Debug.Log("Unity Webplayer");
#endif 

Does anyone know why UNITY_WEBPLAYER would evaluate to true while running in the editor? Is there another way for the build to detect that it is or isn’t a web player? Thanks!

What you are using are compiler switches. They are some kind of constants to tell the compiler at compile time which code it should use. This is "selected" by the target platform you're actually using. If you switch the platform to standalone for example it would ignore the UNITYWEBPLAYER stuff. UNITYEDITOR is a special switch which is only active when Unity creates the temp-build to run inside the editor.

What you need is this: Application.isWebPlayer.