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 equus_ligneus · Mar 05, 2015 at 02:29 PM · c#unity 5editor-scriptingfoldercustom inspector

Unity 5 CustomEditor for Folders

In Unity 4.6.x it was possible to override the way a folder is displayed by writing a CustomEditor for UnityEngine.Object like shown in this Unite-Presentation: https://www.youtube.com/v/SyR4OYZpVqQ?version=3&f=playlists≈p=youtube_gdata (starts at 16:17 mins). For those wondering, Buttons and stuff only worked in the OnHeaderGUI(), but not in the OnInspectorGUI() where they were displayed but inaccessible.

Now that I switched from Unity 4.6 to 5.0, the Folders seem to have changed type (they are of type AssetImporter now). On top of that the OnHeaderGUI() and OnInspectorGUI() do not seem to get called at all any more, whereas the OnEnable() and OnDisable() callbacks still work (That's how I found out about the type change).

Does anyone know a way to get CustomEditors for Folders (fully) working again?

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 RudyTheDev · Mar 05, 2015 at 06:47 PM

Folders react to [CustomEditor(typeof(DefaultAsset))].

Apparently Unity5 ignores the true part of [CustomEditor(typeof(Object), true)] even though DefaultAsset:Object. Thankfully, folders seem to be DefaultAsset, so [CustomEditor(typeof(DefaultAsset))] actually works to receive the OnHeaderGUI() and OnInspectorGUI() callbacks. OnInspectorGUI() comes pre-disabled, but can be GUI.enabled = true;.

Other assets seem to behave the same way. I cannot get C# scripts to show up for [CustomEditor(typeof(TextAsset), true)] (`MonoScript:TextAsset`), but I can for [CustomEditor(typeof(MonoScript))]. (Going from this, I looked at all classes deriving Object and guessed DefaultAsset.) I guess you have to know the concrete type of your asset to do custom editors for assets.

P.S. I too thought they would be AssetImporter-derived or something, but they don't seem to be. AssetImporter stuff uses internal AssetImporterInspector to draw.

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 equus_ligneus · Mar 24, 2015 at 12:31 PM 0
Share

Thanks a lot

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

2 People are following this question.

avatar image avatar image

Related Questions

Trying to create Custom Inspector Labels and I get erros 0 Answers

Building Plugins only for editor 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Custom Inspector to Load Instance Values 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