Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 WaldoAtUSC · Apr 10, 2018 at 03:27 PM · inspectorcustom editorcustom inspector

Custom Inspector "Multi-object editing not supported"

I have been playing with the custom inspector and I can't seem to get it to work correctly with inheritance. Here are my files, I will explain what I tried after the code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class ParentObject : MonoBehaviour {
 
     public int i = 0;
     public int j = 0;
     
 }

Class 2:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class ChildObject : ParentObject {
 
 }
 

Editor Script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 
 [CustomEditor(typeof(ParentObject), true)]
 public class ParentEditor : Editor
 {
     public override void OnInspectorGUI()
     {
         base.OnInspectorGUI();
         ParentObject p = (ParentObject) target;
         EditorGUILayout.LabelField("i", p.i.ToString());
     }
 }

I attached both classes to the main camera to see the inspector. In this set up both say "Multi-object editing not supported". When I remove the editorForChildClasses boolean the child class will show the expected (allows me to modify i and j) but ParentObject is still the same.

I want to have it so that I can have a few things in the Parent Editor then have another editor for the child class that has its own stuff along with the parent stuff.

Thanks for any advice!


Update 1: For some reason the Editor script started to work for ParentObject. I added a new editor script to the Editor folder to test it and it started working. It still doesn't work for ChildObject when editorForChildClasses is on but it's a step in the right direction.

Comment
Add comment · Show 1
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 WaldoAtUSC · Apr 10, 2018 at 03:35 PM 0
Share

I've seen that a common cause of this problem is the file isn't in the Editor folder, that isn't the cause of my problem, but maybe it will help someone else that has this happen.

4 Replies

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

Answer by WaldoAtUSC · Apr 10, 2018 at 05:13 PM

Okay, kind of an annoying work around but this works, hope it helps someone:

ParentObject and ChildObject are the same

Added a method to ParentEditor:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 
 [CustomEditor(typeof(ParentObject))]
 public class ParentEditor : Editor
 {
     public override void OnInspectorGUI()
     {
         ParentObject p = (ParentObject) target;
         EditorGUILayout.LabelField("i", p.i.ToString());
         EditorGUILayout.LabelField("j", p.j.ToString());
     }
 
     static public void RunForChild(ChildObject c)
     {
         ParentObject p = c;
         EditorGUILayout.LabelField("i", p.i.ToString());
         EditorGUILayout.LabelField("j", p.j.ToString());
     }
 }

Made a ChildEditor class:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 
 [CustomEditor(typeof(ChildObject))]
 public class ChildEditor : Editor
 {
     public override void OnInspectorGUI()
     {
         ParentEditor.RunForChild((ChildObject)target);
     }
 }


Kind of annoying that it didn't just work, but this is fine for me.

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 EdauardsBrown · May 17, 2020 at 01:32 PM 0
Share

You can use:

 [CustomEditor(typeof(ParentObject), true)]


The second property enables Editor For Child Classes

avatar image
13

Answer by stephanholding · Mar 01, 2019 at 12:40 PM

You can use [CustomEditor(typeof(ParentObject)), CanEditMultipleObjects]. This way you can edit multiple instances of your custom editor in the inspector, at the same time.

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 Bunny83 · Mar 01, 2019 at 02:53 PM 1
Share

While this is true, just adding this attribute is not enough. The actual editor code has to handle multiple objects as well, which his code doesn't since he uses the "old" target object. $$anonymous$$ulti-object editing should be done with the SerializedObject / SerializedProperty classes. Every editor already has the serializedObject property.


If you can't or don't want to use the SerializedObject, you have to use the "targets" array and do any multi object relevant things yourself. The targets array will contain all objects. Though if you don't know what you're doing, it's easy to completely mess up everything.

avatar image
3

Answer by Dailyalex · Nov 06, 2021 at 01:50 PM

My anwser is not exactly about inheritance, but I got same error message. That's why maybe my anwser will help to somebody.

I had simplier example and i was pretty sure, that code looks good, but I still got this warning message. What I did, I just removed component and added it back. And this warning dissapeared.

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 PoisonousPurple · Nov 10, 2021 at 12:49 PM 0
Share

Doing this one in after doing what stephanholding did worked perfectly for me :D

avatar image gadoy- · Nov 11, 2021 at 09:58 PM 0
Share

True hero!

avatar image
0

Answer by zibolo · Apr 23 at 10:41 AM

For me I solved the problem by making sure that the name of the editor script/class was the same as the name of the class of which I wanted to modify the editor + "Editor". So if your class is called "MyObject", the editor class should be called "MyObjectEditor". And everything worked smoothly.

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

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

Related Questions

Should I use Inspector or custom editor window? 1 Answer

Inspector Overlapping Text Label at a Position 1 Answer

Custom editor UnityEvents in List 0 Answers

Custom inspector editor - how to put new editor fields in a specific place 1 Answer

Show texture (image box) in inspector with custom editor [C#]? 3 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