• 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 steinbitglis · Feb 20, 2012 at 10:35 PM · inspectorplatform

Unity 3.4 with 3.5 attributes

I can't figure out how to use inspectors that support editing multiple objects while still being compatible with unity 3.4. I've made something that actually compiles, but the inspector falls back to default. I have no idea why, because the declaration is there, and it causes the custom inspector to show up when I don't use a macro.

How do I use [CanEditMultipleObjects] without breaking Unity 3.4 compatibility?

 macro declare_my_class:
     body = [|
         pass
     |]

     ifdef UNITY_3_4:
         yield [|
             [CustomEditor(MyClass)]
             class MyClassEditor (Editor):
                 $body
         |]

     ifdef UNITY_3_5:
         yield [|
             [CustomEditor(MyClass), CanEditMultipleObjects]
             class MyClassEditor (Editor):
                 $body
         |]

 declare_my_class true
Comment
Add comment · Show 10
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 ina · Feb 21, 2012 at 12:30 AM 0
Share

Typically when I bring my project from Unity 3.5 to 3.4, the entire project "breaks" due to differences in prefab systems. How are you getting this to work from the IDE perspective?

avatar image steinbitglis · Feb 21, 2012 at 01:10 AM 0
Share

I use a really powerful text editor, called Vim. It doesn't care about deep code analysis, but it's blazing fast and epic for writing all kinds of code. IDE's tend to make me slower. I hardly think there's any IDE that will dig through these macros anyway. It's just not worth it.

avatar image ina · Feb 21, 2012 at 01:43 AM 0
Share

Other than advantages for macro's does Vim allow code complete and such (for Unity API stuff)?

avatar image steinbitglis · Feb 21, 2012 at 02:38 AM 0
Share

Vim does not handle code completion for macro's or any other code, unless you use plugins. The important thing is, that it's a powerful text-editor. It does simple word-completion, based on your open files, but that's all the code completion I have time to wait for; Its sufficient most of the time. The downside is that Vim takes a long time to master. For the same reason, it's also the most ergonomic text editor you'll ever use, if you care about such. ($$anonymous$$aybe I should look for some solution for the Unity API, since I spend a lot of time with Unity these days.)

avatar image Tseng · Feb 21, 2012 at 02:31 PM 0
Share

That's pretty useless when you ask me. You lose more time by looking for all kind of $$anonymous$$ethod, Properties and variable names in the documentation than you save by it being "lightweight". Proper IDEs (like $$anonymous$$icrosoft Visual Studio) makes program$$anonymous$$g 20 times faster and more comfortable.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by steinbitglis · Feb 21, 2012 at 11:57 AM

I managed to write something that works, but I'm not proud of it. I basically rewrote the thing to C# and dropped macro support.

 using UnityEngine;
 using UnityEditor;
 
 #if UNITY_3_4
 [CustomEditor(typeof(MyClass))]
 #endif
 #if UNITY_3_5
 [CustomEditor(typeof(MyClass)), CanEditMultipleObjects]
 #endif
 public class MyClasseditor : Editor {
     // Lots of code here
 }
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 Tseng · Feb 21, 2012 at 04:37 PM 1
Share

Narf. I managed to delete my own comment ins$$anonymous$$d of editing it xD

You can just move the 3.4 part in the #elif directive.

 #if UNITY_3_5
  // Unity 3.5 specific
 #elif 
  // everything other than 3.5
 #endif

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

8 People are following this question.

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

Related Questions

Color Picker not supported on this platform 1 Answer

Do I have to change the value of a pubilic variable in the script even if I have already changed the value in the inspector variable? 3 Answers

How do i call a function in main script from editor script? 1 Answer

UnassignedReferenceException when its already assigned 1 Answer

How to access one class instance in editor script? 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