How to get the current target platform?

Hi guys,

The title says it all, I am trying to find a way to get the current platform Unity is targeted on. Everything must be checked while in-editor.

Thanks! :slight_smile:

1 Like

Use Preprocessor Directives to run sections of your code on specific platforms and tag the top of the script with [ExecuteInEditMode] to run in editor.

3 Likes

You mean this Unity - Scripting API: EditorUserBuildSettings.activeBuildTarget ?

10 Likes

Thanks! EditorUserBuildSettings.activeBuildTarget works flawlessly! :smile:

6 Likes

Worked for me as well! Many thanks for โ€œdirectionโ€ :slight_smile:

This will only work in Editor, not in build games.

Hi, I found this: Unity - Scripting API: Application.platform (unity3d.com).
Hope it can help you out :slight_smile:

1 Like