0 votes

Is there a way to have platform specific code in Godot so that if your on a specific platform, certain code will run. Something like this maybe:

#if Windows
        //do windows specific thing
#elif Android
        //do android specific thing
#endif
in Engine by (37 points)
edited by

1 Answer

0 votes
Best answer

Yes. There is a function for that in the Godot.OS Class:

//
// Summary:
//     Returns the name of the host OS. Possible values are: "Android", "iOS", "HTML5",
//     "OSX", "Server", "Windows", "UWP", "X11".
[GodotMethodAttribute("get_name")]
public static string GetName();
by (710 points)
selected by

Is there a way to do this using preprocessor directives?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.