Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by DarkPixel · Feb 11, 2014 at 02:07 AM · c#versionpreprocessor

Preprocessor for Unity version higher than 4.3

I need a way to define a preprocessor in C# that tell if the Unity version is higher than 4.3. In C++, it would be easy with .h but I'm not sure it's possible in C#. And I need that in the editor

ex:

 #if UNITY_VERSION > UNITY_4_3
 #define UNITY2D
 #endif
 
 #if UNITY2D
 //do 2d stuff
 #endif
Comment
Add comment
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

1 Reply

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

Answer by Eric5h5 · Feb 11, 2014 at 02:53 AM

 #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
 #define PRE_UNITY_4_3
 #endif
 
 #if !PRE_UNITY_4_3
 // do 2D stuff
 #endif
Comment
Add comment · Show 7 · 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 Eric5h5 · Feb 11, 2014 at 02:53 AM 0
Share

Assu$$anonymous$$g you actually meant "equal to or higher". Since there's nothing newer than 4.3 at the moment....

avatar image DarkPixel · Feb 11, 2014 at 01:30 PM 0
Share

Yes it's something like this I want. But is there a way to not doing that in every file? Like a C++ .h include?

avatar image Eric5h5 · Feb 11, 2014 at 07:45 PM 0
Share

Not that I know of.

avatar image DarkPixel · Feb 11, 2014 at 07:48 PM 0
Share

I searched and I think it's impossible, so the only way is your answer in all file. Thanks

avatar image ABerlemont · Jan 22, 2016 at 10:31 AM 0
Share

Is it possible to have a >= ? For current AND futur newer version of Unity3D ?

avatar image Bunny83 ABerlemont · Jan 22, 2016 at 11:43 AM 0
Share

No, it's not. Preprocessor symbols are just symbols. You can check if it exists or not. The symbol doesn't have a value or something like that. They are like boolean switches.

They could have implemented something like version-feature switches, however since there are more and more breaks between newer and older version of Unity it would be pointless. There are newer things that doesn't exist in older versions as well as old things that doesn't exist anymore in current versions.

You should simply pick a $$anonymous$$imum version required and for small differences use preprocessor switches.

Who would develop something that relies heavily on Unitys 2D features and announce it to be compatible with Unity 2.6? Preprocessor switches can be used to fix for $$anonymous$$or differences between version. Though it always the best to use the most common features. For example the shortcut properties except "transform" has been removed. However GetComponent<SomeComponent>() does work in all versions.

avatar image ABerlemont Bunny83 · Jan 22, 2016 at 01:50 PM 0
Share

"however since there are more and more breaks between newer and older version of Unity it would be pointless"

Very true. Thanks for the insight.

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

22 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Can I create a global function/variable without a class in c#, or to skip reference to it? 1 Answer

Does Unity define a Preprocessor Directive for 'UNSAFE'? 0 Answers

An OS design issue: File types associated with their appropriate programs 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