Execute Editor and Android Code Seperately

I want to execute editor code in Unity editor and Android platform code in android devices. So that I partition my code like this but always getting Android platform code executed in Unity Editor too.

2654187--187065--Screen Shot 2016-05-27 at 12.31.49 PM.png

My Player Setting is running like this:

2654187--187066--Screen Shot 2016-05-27 at 12.44.47 PM.png

So I want to execute editor code in Unity Editor and Android code in Android Devices. This is my basic requirement. Please give some help in this.

EDIT: In other words, how can I say that it is actual android device or Unity editor running this??

I believe you could just swap the compiler definitions, making UNITY_EDITOR always check first in your code.

@KyleOlsen Thanks for your reply but I am not getting you in this.

Can you give me some more details?

Like this, make sure you always run your checks for the editor first.

#if UNITY_EDITOR
        // Run editor only code
#elif UNITY_ANDROID
        // Run android only code
#endif

@KyleOlsen Okay I get this :slight_smile: