Platform depended script. Bug, or confusion?

Hi guys, I’m running a bit of platform dependant code so that I can get my editor working with the mouse, and the iPhone working with touch, using the same code.

Works fine on the iPhone, but in the editor, it appears to run BOTH.

It seems the editor is saying "Yes, this is editor code and I’ll run it. Yes, I’m deploying for iPhone, I’ll run that too.

#if UNITY_IPHONE
    Debug.Log("I'm an iPhone!");		
#endif	
#if UNITY_EDITOR
    Debug.Log("I'm the editor!");
#endif

It cleary prints both when I run my game in the editor.

How can I stop it running the iPhone Code, without switching the projects platform?

http://unity3d.com/support/documentation/Manual/Platform%20Dependent%20Compilation.html “Furthermore, you can run this code within the Editor, so you can compile the code specifically for your mobile/console and test it in the Editor!” It would be a problem if code intended for iOS didn’t run in the editor; e.g. you couldn’t test it with Unity Remote. You can do this though:

#if UNITY_IPHONE  !UNITY_EDITOR
    Debug.Log ("Only iOS");
#else
    Debug.Log ("Other platforms");
#endif

–Eric

Aha, thank you Eric!

What you’ve said make perfect sense, that’d why I had confusion appended to my thread title.

Would be nice if the documentation had your little code snippet in it.

Thanks again