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
3
Question by geroppo · Mar 30, 2013 at 01:10 AM · editorinspectorwindowcustom

Call inspector on custom window editor

Hi there, here is the thing: in my scene i have several objects and each one of them have like 5 or 6 script components, and each one has several config options. So for organization's sake i decided to make a custom window that shows a node-like view of your selected gameobject, and it displays in a 2d view all the components that conform that game object ( and how they interact with each other, with arrows). When you select one component in that 2d view, a second inspector windows comes in showing you only the component that you selected so you can modify their options.

The problem is how to represent that inspector-like window, i've been searching alot but with no result. And on top of this, some scripts have a custom inspector script so that's why i'm trying to call an inspector window here. Does anyone know if this kind of thing is possible ? otherwise i would like to know if there is a better or different solution to this organization thing. Of course its not critical, but would help alot having one of this. Cheers

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

4 Replies

· Add your reply
  • Sort: 
avatar image
9

Answer by MaxEden · Sep 10, 2015 at 04:12 PM

 Editor editor = Editor.CreateEditor( gameObject );
 editor.DrawDefaultInspector();

I don't know how to draw it in specified area, but it works for plain drawing inside EditorWindow and even inside custom layout areas.

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 IgorAherne · Jul 15, 2017 at 10:32 PM 3
Share

to draw it in specified area, use this:

 Rect myRect = new Rect();
 myRect.center = Vector2.one*200;
 
     GUILayout.BeginArea(myRect);
     myEditor.DrawDefaultInspector(); //confines the editor to the specified rectangle
     GUILayout.EndArea();


avatar image
0

Answer by Loius · Mar 30, 2013 at 05:22 AM

There's not really a way to call an inspector, unfortunately. You'd have to provide a function for each component, even the ones you'd rather have default inspector on.

If you're wondering about creating an actual editor window, you can use EditorWindow to do that.

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 geroppo · Mar 30, 2013 at 06:33 PM 0
Share

yes that's actually what im doing, inside that editor window i was trying to display that 2d space with the little nodes representing the components of the object. it's such a shame that you don't have a little more freedom for controlling the inspector. Btw do you know a way for at least "call" the inspector window and dock it to the new custom window you just created ? (when using EditorWindow.GetWindow(typeof(WindowToDock));

avatar image Loius · Mar 31, 2013 at 08:16 PM 0
Share

I don't see an 'auto-dock' option, though what I did for a similar little excursion was I created my main Window in two Vertical layouts, and called th GUI function of the edited object in the second panel:

 var editedObject : $$anonymous$$yEditableBaseClass;

 function OnWindowGUI() {
   GUILayout.BeginHorizontal();
     GUILayout.BeginVertical();
       // $$anonymous$$ain window GUI goes here, picks editedObject from its components
     GUILayout.EndVertical();
     GUILayout.Label(/*line texture*/);
     GUILayout.BeginVertical();
       editedObject.ShowEditorGUI();
     GUILayout.EndVertical();
   GUILayout.EndHorizontal();
 }

There's also EditorWindow.ShowAuxWindow; I've never used that myself but it sounds like maybe a thing you'd be interested in trying.

avatar image geroppo · Mar 31, 2013 at 09:11 PM 0
Share

well thanks! that helps alot in the distribution window thing. now there only remains the inspector window problem. I'm thinking i could create ( not very happy with this tho ) a new gameobject in the scene or as an asset, extract from the original object the component i wish to inspect, and paste it in the new temporal object. Then i could give focus to that object to show up in the inspector, and after finishing changes i could copy back that component to the original object. the thing im not happy with is creating a whole new game object with will have the transform component, so im still thinking and searching for another ways. Thanks for your comment !

avatar image
0

Answer by LaireonGames · Dec 03, 2018 at 12:41 PM

Based upon @MaxEden 's answer this is how to do it with a custom inspector rather than the Unity default one:

 AchievementEditor editor = (AchievementEditor)Editor.CreateEditor(achievement.objectReferenceValue, typeof(AchievementEditor));
             editor.OnInspectorGUI();

Where AchievementEditor is the name of my custom editor.

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

Answer by CaJerry87 · Jul 05, 2020 at 09:52 PM

This is more of a conceptual suggestion but what if you just added a new inspector tab and then saved the layout? Let unity remember that you want to have an inspector there(instead of hard coding it). Also, look into Bolt. It's a node-based programming asset purchased and released by Unity. It costs a pretty penny but I think its right up your alley and would let you get deeper into your projects.

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

15 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

Related Questions

Can a GameObject's full inspector be drawn in a custom Editor Window ? 1 Answer

Open new editor window from editor class 2 Answers

Unity editor and inspector header 0 Answers

Custom Inspector Variables 1 Answer

Draw inspector for SerializedObject within EditorWindow? 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