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 kakyoism · Mar 20, 2012 at 06:49 PM · editorwindowsmac

How to know if I'm running UNITY_EDITOR on Windows or Mac?

I have a script that I like to run on Windows/Mac in Unity Editor, which is truly platform dependent. I found that UNITY_EDITOR will be effective for both platforms, but there is no obvious way to tell if I'm running the editor on Windows or Mac.

Any ideas? Thanks!

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by DaveA · Mar 20, 2012 at 06:51 PM

I see these options here: http://unity3d.com/support/documentation/ScriptReference/RuntimePlatform.html

Comment
Add comment · Show 2 · 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 mark_madatom · Nov 05, 2014 at 11:17 AM 0
Share

That's for runtime but the original poster was asking about the editor platform, so that's the wrong answer.

avatar image Demigiant · Jan 03, 2015 at 12:33 PM 0
Share

Actually those should work even while in the editor (see my answer below)

avatar image
2

Answer by solarisn · Nov 18, 2018 at 01:21 AM

UNITY_EDITOR_WIN and UNITY_EDITOR_OSX are available in the latest versions of Unity. Not sure which version this got introduced, though.

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
1

Answer by Demigiant · Jan 03, 2015 at 12:27 PM

Application.platform should return the correct result while in the editor.

 bool isWinEditor = Application.platform == RuntimePlatform.WindowsEditor;
 bool isOSXEditor = Application.platform == RuntimePlatform.OSXEditor;


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 mark_madatom · Nov 05, 2014 at 11:31 AM

I needed to do this, but couldn't find anything in Unity itself, so ended up using a .NET Framework API. Below is the code I use, which is based on the code in the answer to the "How to detect the execution platform?" question in the Mono technical FAQ. It returns false on Windows and true on Mac (and other Unix-like OSes):

     public static bool IsUnix()
     {
         var platform = (int)System.Environment.OSVersion.Platform;
         return (platform == 4) || (platform == 6) || (platform == 128);
     }
 

More details at http://www.mono-project.com/docs/faq/technical/ and http://msdn.microsoft.com/en-us/library/3a8hyw88(v=vs.110).aspx.

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

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

7 People are following this question.

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

Related Questions

Application.CaptureScreenshot() Fails on PC/Mac 2 Answers

Overall quality became worse after changing to Windows from Mac 1 Answer

Can I develop an iphone app on UnityPro3d (for windows) and then transport it to Unity (iphone version for mac)? 2 Answers

Compile a game for iOS, Mac, PC - how much adjustment? 2 Answers

Unity 3D White Screen Error 0 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