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 dfalcone · Sep 18, 2013 at 10:48 AM · overridecustomeditor

Can you override a customeditor if it already exists?

Unity has some already defined custom inspectors, for example in the mecanim system. I'd like to be able to override some, but it seems that [CustomEditor(typeof(object))] only works the first time it is loaded. Is there any way to override one that is already defined?

For example: [CustomEditor(typeof(Transition))] is already defined in UnityEditor.dll, so I'm trying to figure out how to have my own Transition inspector custom editor.

Comment
Add comment · Show 4
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 syclamoth · Sep 18, 2013 at 10:51 AM 0
Share

Short answer- Nope! In fact, you can't even make subclasses of almost all of the Unity API classes. Why do you need to do this? A somewhat messier way would be to create a 'dummy' monobehaviour you can attach to the relevant gameObjects, and use the editor to that. The component itself should not have any actual behaviour (except maybe deleting itself at runtime!), but should have a reference to the Transition component you want to make a custom editor for.

avatar image dfalcone · Sep 18, 2013 at 11:41 AM 0
Share

Thanks, I don't need to do this, but I would like to. I'm adding other events to the state machine and thought it would be nicer to add to the UI that already exists ins$$anonymous$$d of making a completely new one. This seems like a reasonable feature to have in my opinion. It would be nicer if the last loaded [CustomEditor] was used ins$$anonymous$$d of the first loaded one.

avatar image syclamoth · Sep 18, 2013 at 11:46 AM 0
Share

'nicer to add to the UI that already exists ins$$anonymous$$d of making a completely new one'

... this is exactly what creating a custom editor for your own classes does.

You must understand that the folks at UT aren't too keen on end users introducing bugs into their interface code and then co$$anonymous$$g back crying about errors. That said, I do wish they would release more of their source code- there's a lot we can learn from looking at exactly how the built in editor stuff actually works.

avatar image dfalcone · Sep 19, 2013 at 11:01 AM 0
Share

I wanted to make the question short and simple, but so you know that I know what I'm asking for, there are multiple GUI windows involved in the state machine. The managed assembly also contains the source code for these inspector classes, so they are easy to replicate and add on to. Additionally, for the more difficult items, using assembly reflection seems to be a quick and dirty way to reuse and add on to the existing toolset, though unfortunate it could break between versions.

I thought of a workaround this morning. I'll have an editor window that monitors when items are active, then start a different customeditor. That way, even though Unity's will initially load, it will quickly be replaced with my new one.

1 Reply

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

Answer by dfalcone · Sep 19, 2013 at 11:34 AM

Confirmed workaround for this problem.

I used an EditorWindow for my tool which also monitors what current selected objects are. For this example, I'm editing a State object since the Transition object I mentioned in my first post is not exposed (internal class). The 'StateEventEditor' is my own customeditor class.

In the EditorWindow:

 private static State lastSelectedState;

 void OnEnable () {
     EditorApplication.update += Update;
 }
 
 void Update () {
     if( Selection.activeObject.GetType() == typeof(State) ) {
         if( Selection.activeObject != lastSelectedState )
             Debug.Log("State selected");
             lastSelectedState = (State)Selection.activeObject;
             StateEventEditor stateEventWrapper = new StateEventEditor(lastSelectedState);    
         }
     }
 }
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

17 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

Related Questions

Overriding "Ctrl +" in Custom Editor 0 Answers

Override windows onaly allowing three buttons being pressed 1 Answer

Working with Facial Animations in Mecanim 3 Answers

Sprite.OverrideGeometry() doesn't work? 1 Answer

Weird behaviour of an editor extension that sets variables on other scripts. 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