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
0
Question by kc_wired · Jun 19, 2013 at 11:29 PM · unityeditorwindowsmaccompile

UnityEditor Pre-compliler Defines for differentiating between Windows & Mac OSX

We are using Unity in an Windows & Mac OSX environment, with our primary development environment being Windows. This means that some of our plugins and tools are Windows Specific. I would like to be able to exclude and/or include Windows vs Mac OSX environment specific components (Assets, Scripts, Libraries, etc.).

Is there a pre-compiler define? Is there another way to determine this without using the RuntimePlatform API? Is there way to determine the environment from the Unity Executable?

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
0

Answer by iwaldrop · Jun 19, 2013 at 11:57 PM

Yes, there are defines for standalone platforms. See this page.

In short, you want either UNITY_STANDALONE_OSX or UNITY_STANDALONE_WIN.

In order to tell whether the Unity Editor is running on a particular platform, use these enum flags:

RuntimePlatform.OSXEditor and RuntimePlatform.WindowsEditor

Comment
Add comment · Show 4 · 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 kc_wired · Jun 20, 2013 at 01:27 AM 0
Share

Hi iwaldrop,

Yes, I am aware of the Pre-compiler defines, but they are Windows & $$anonymous$$ac OSX environment agnostic. They are used for the targeted UnityEditor Player and the Windows & $$anonymous$$ac Standalone Players.

ie. #if UNITY_EDITOR && UNITY_STANDALONE_WIN will still return true when running UnityEditor on $$anonymous$$ac.

One such scenario that I am dealing with is GamePad Input when using the UnityEditor on Windows vs $$anonymous$$ac has to be mapped uniquely for each environment. If I use the above #if UNITY_EDITOR && UNITY_STANDALONE_WIN, while developing on a $$anonymous$$ac, then the GamePad Input mappings will be incorrect.

I believe I can achieve the result I want via RuntimePlatform API. Unfortunately that does not solve issues with say Windows vs $$anonymous$$ac compatible .dlls that must be included/excluded from the environment via the AssetPostprocessor API.

avatar image iwaldrop · Jun 20, 2013 at 01:36 AM 0
Share

First, I've converted your answer to a comment.

Second, I misunderstood that you were talking about running the Unity Editor. Use these enum flags to check for the editor.

RuntimePlatform.OSXEditor and RuntimePlatform.WindowsEditor

You'll probably want to wrap them, like so:

 #if UNITY_EDITOR
 if (Application.platform == RuntimePlatform.OSXEditor)
 {
     // do osx editor stuff
 }
 else if (Application.platform == RuntimePlatform.WindowsEditor)
 {
     // do windows editor stuff
 }
 #endif


avatar image iwaldrop · Jun 20, 2013 at 01:45 AM 0
Share

Damn...I'm in a hurry today and didn't read the last part of your comment. Yeah, that kind of sucks. One way around it may be to use Actions and Funcs to encapsulate platform functionality. Another way might be to use an interface to instantiate particular classes based on the platform that you're using. Alas, I don't have any experience with running in multi-platform development environments. Sorry, and good luck!

avatar image kc_wired · Jun 20, 2013 at 07:04 PM 0
Share

Thanks iwaldrop for your responses and I will take your suggestions into consideration. I may just ping Unity Tech support for a feature request if I don't stumble upon a solution.

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

15 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

Related Questions

Mac VS Windows Builds 3 Answers

Mesh vertex count differs on Mac/Windows 1 Answer

Git to sync Mac and Windows folder of same project 1 Answer

"Out of Memory" on Windows Build, Runs perfectly on Mac Build 1 Answer

Compiling Universal App in windows which won't run on my Mac 2 Answers


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