Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Tim0n · Feb 22, 2017 at 02:42 PM · inspectorcustom-inspectorcomponentsstate-machine

Indent or resize entire components in custom inspector

Hello!

Now I'm not sure if this is even possible, after what feels like a ton of googling I can't come up with any answers so I'm asking the question here instead. I have made a component-based hierarchial state-machine in unity and got it to work pretty well. Unfortunately I do have the knowledge for how to make a node-based Editor in Unity and can't really find any tutorials that are free and looks good so I have for now settled with having the ftm in the inspector.

The problem I am trying to solve right now is if it is possible to indent entire components, each state in my state machine is a component, and what I would like to to do in my custom inspector is to indent each state that is a substate to another, thereby creating a nice hiearchy where you can clearly see state and substates in the editor. Although I'm not finding any way to actually controll the component widht, height or even indention level. So I am wondering if this is even possible, if it is not, does anyone at least know a way to get the position of an component in the inspector so I can insert color-based rects to tell which state belong to eachother.

Grateful for any answers, and I apologise for the tl;dr.

Best, Simon

EDIT: Here's a image of kind of what I am looking for, sorry if I confused anyone. alt text

indentplz.jpg (230.6 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by gameplay4all · Feb 22, 2017 at 03:09 PM

https://docs.unity3d.com/ScriptReference/EditorGUI-indentLevel.html

 EditorGUI.indentLevel

Should do the trick if you are using GUILayout. :)

-Gameplay4all

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 Tim0n · Feb 22, 2017 at 05:59 PM 0
Share

Hello and thank you for answering!

Unfortunately this was not exactly what I was looking for, I was looking to indent the entire component "window" so that the component would visusally be further into to the inspector than another component, I know this is also an awful explanation of the problem but I added a image of how I would kind of like it to be in the original post.

If you indeed did mean that it would be able to do what was intended in the image then it must be my implementation that is wrong with and I will look further into it under such circumstances.

avatar image gameplay4all Tim0n · Feb 22, 2017 at 07:00 PM 1
Share

Ah, okay. Well that would be hard to pull off, if not impossible. You can write custom inspectors for every component your system is using so you can at least indent all the fields and remove the "script" field. But I am pretty sure you can't indent component headers. I am of no further help here I'm afraid :( Good luck!

avatar image
0

Answer by RobAnthem · Feb 22, 2017 at 06:37 PM

If you are doing a recursion, then I might suggest something like this.

     void IterateStates(State state)
     {
         if (state.States != null)
         {
             foreach (State enemyState in state.States )
             {
                 if (enemyState != null)
                 {
                     EditorGUILayout.BeginHorizontal();
                     GUILayout.Space(15 * stateHierarchy);
                     EditorGUILayout.ObjectField(enemyState, typeof(State), false);
                     EditorGUILayout.EndHorizontal();
                     stateHierarchy++;
                     IterateStates(enemyState );
                     stateHierarchy--;
                 }
             }
         }
     }
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

6 People are following this question.

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

Related Questions

Questions Regarding Images in Custom Inspector/Editor 1 Answer

Creating enum using a string array 3 Answers

Reorderable list of UnityEvents 2 Answers

Make a custom inspector that shows a group of variables in form of list 2 Answers

How do I change inspector values of other game objects using a custom Editor Window 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