Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by 00yoshi · Sep 06, 2015 at 02:17 PM · c#platformcompilerplatforms

#if UNITY_ANDROID doesn't exists in unity 5

I want to make a platform dependent compilation in a class, but UNITY_ANDROID doesn't exist in MonoDelevop, the only things which exist beginning with UNITY_ are: UNITY_5, UNITY_5_1, UNITY_5_1_1, UNITY_ASSERTIONS, UNITY_EDITOR, UNITY_EDITOR_64, UNITY_EDITOR_WIN, UNITY_STANDALONE, UNITY_STANDALONE_WIN. I didnt find a solution on google and the help page in the docs says that things like UNITY_ANDROID exist. It looks like this:http://puu.sh/k1Ty4/1da995c04f.png

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Adamcbrz · Sep 06, 2015 at 05:30 PM 1
Share

What platform do you have selected on your build settings,

avatar image hexagonius · Sep 06, 2015 at 05:50 PM 0
Share

they should exist, I use them with Unity 5.1.2f4 maybe making the endif followed by if an elif (for elseif). Also try resyncing mono from Unity via Assets > Sync $$anonymous$$onoDevelop Project). 

3 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Positive7 · Sep 06, 2015 at 07:14 PM

Change your build settings to Android and it will Popup in MonoDevelop. You can keep continue using #if UNITY_ANDROID while build settings is set windows or whatever. Once you change to Android it will get compiled.

You can also check it if you click Build Settings -> Android -> Switch Platform then switch to mono and check your code highlight as normal inside Android endif and any other platform become gray highlight (skin dependent color).

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Binbag42 · Feb 24, 2016 at 09:21 AM 0
Share

I have the feeling the "problem" comes from $$anonymous$$onoDevelop as:

  1. it does not offer autocompletion for UNITY_ANDROID if build settings are set to something else than Android

  2. it does not offer autocompletion inside #if UNITY_ANDROID #endif

avatar image
1

Answer by Bloke28 · Apr 02, 2019 at 11:47 PM

I like to use both, what it does is says if build settings are android, then add this code, and then if your current system device is android then run this code. So when in editor testing it won't run the code but it remains there if your build settings are set to android.

The Same can be done for the editor.

 #if UNITY_ANDROID
         if(Application.platform == RuntimePlatform.Android)
         {
          /* Do Stuff */ 
         }
     #endif
 
 #if UNITY_EDITOR
         if (Application.platform == RuntimePlatform.WindowsEditor)
         {
             Debug.Log("Button Pressed in Editor");
         }
     #endif




Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Don-Tako · Nov 14, 2018 at 01:16 PM

You also can do:

 if(Application.platform == RuntimePlatform.Android)
 {
  //... do stuff
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Nov 14, 2018 at 08:22 PM 0
Share

This is not the same thing as this code stays while the other gets completely stripped.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

33 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

my platform goes up but doesnt come back down? 1 Answer

Help me with gui please (C#) 2 Answers

I got three CS 1061 Errors while learning Unity as an absolute beginner. Please help me! 1 Answer

compiler error - playmode 0 Answers

Why is my moving platform getting stuck? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges