• 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 dCalle · Oct 30, 2017 at 11:55 AM · librarypreprocessorsymboljit

Get preprocessor symbol UNITY_EDITOR for 3rd party Library

Hey, I'm working on an custom Inspector that fully replaces the original Inspector.

I'm compiling it to a library, because i t$$anonymous$$nk not doing that would slow down recompilation. correct me if i'm wrong.

But I'm stuck with yet another problem: I can't use #if UNITY_EDITOR anymore. is there a way to import t$$anonymous$$s symbol and make it part of a JIT compilation?

Or do I have to provide a .cs file that takes care of it outside that library. And How would I do that (a Library Handler)?

I'm confused, overwhelmed and do feel freaking stupid right now... ( next level issues I guess^^)

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
2
Best Answer

Answer by Bunny83 · Oct 30, 2017 at 01:04 PM

Actually there should never be a reason to use that preprocessor define at all. You generally should seperate runtime and editor code. Editor scripts (and editor assemblies) should be in an editor folder. Also keep in mind that the more recent Unity versions do have special import settings for assemblies w$$anonymous$$ch allow you to specify for w$$anonymous$$ch platform they are ment for / should be used for. The "editor" is also a platform.


It should be obvious that compiler pre-processor tags can't be used at all since they are only read by the pre-processor w$$anonymous$$ch pre-processes your code files before the code is even compiled. So the the actual compiler doesn't see pre processor tags at all. So of course you can't find any traces of those tags in a compiled assembly.


If for some reason you don't want to seperate editor and runtime code (though you should just like Unity itself: UnityEngine.dll and UnityEditor.dll) You would need to compile two versions of your assembly and put both in your project. The "runtime" assembly must be imported to not be used in the editor w$$anonymous$$le the "editor" assembly must only be used on the editor platform. Though such a setup may work for you but i wouldn't recommend to use such an approach when you want to publish it on the asset store.


As i said it's generally a better approach to seperate runtime and editor code. Where / for what do you actually use the tags?

Comment
Add comment · Show 3 · 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 Glurth · Oct 30, 2017 at 06:44 PM 0
Share
avatar image Bunny83 Glurth · Oct 31, 2017 at 01:03 AM 1
Share
avatar image Glurth Bunny83 · Oct 31, 2017 at 08:43 AM 0
Share

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

73 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What C# predefines are recognized by Unity? 3 Answers

PreProcessor Directives have suddenly stopped working 0 Answers

How do I open an existing project in Unity? 6 Answers

Can I read the UnityEngine Library? 2 Answers

play video from iphone photo library 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