Unity Editor Scripting: Custom Inspector Tabs
HTML-код
- Опубликовано: 31 авг 2017
- In this Unity Editor Scripting tutorial, we will create custom inspectors with tabs using GUILayout.Toolbar.
MORE...
SUPPORT MY WORK!
My tutorials will always be released to the public for free so anyone can learn. If you have received value and wish to support my work, there's a few options!
ASSET STORE - I publish asset at Unity Asset Store. Purchase my assets and give them a good rating :)
www.assetstore.unity3d.com/en...
PATREON - Become a Patron, join us on Google Hangouts, ask me questions directly!
/ nurfacegames
PAYPAL - Make a tip directly to me via Paypal. Huge thanks!
paypal.me/nurfacegames
All support is very much appreciated and helps the channel grow and become better. Thank you!
Why didn't you store the tab index variable in the editor class? The functional class doesn't need to know anything about tabs or things that are inspector's business. Which tab is active is a sole property of the inspector and should stay in the in inspector. To find out who's property the tab index is, you ask yourself "if I'm thinking of changing the way the inspector is drawn and not use tabs, but something else, does the tab index variable still makes sense to be in the model class?".
I like it, because if I select another GO in the hierarchy and come back, I still have the same tab open. Would there be a way to "serialize" the tabIndex when it's in the editor class? (honestly interested!)
@@michaelmenzi8334 If that's a usecase for you, try at least to decouple the tab concept from the GO.
Perhaps instead of keeping a tabindex var in the GO, the GO would have states. These states would abstract the notion of tabs or other viaual form.
The inspector however, knows how to give a visual meaning to the GO's state by rendering the right tab corresponding to the GO's state.
This way your GO keeps its state serialized and doesn't mind how the state is visually represented and the inspector uses the GO's serialized state to visually represent it in it's own manner.
In other words, you decouple the model from the presentation layer. And at anytime you can change the inspector as you please without changing the GO. Perhaps another inspector would use a different visual representation to represent the GO's state.
@@AlexTuduran hey thank you very much for the constructive inputs!
I initially had my mouse hovering over the like for your original comment, because I really appreciate coupled designs and I get your point.
Then I did a few tests and came up with this usecase, which I think is thoroughly convenient, but I'm very new to editor coding (that's why I'm here ;)).
I'll have to think about your inputs for a few minutes (or hours ^^) and what those mean design-wise for my project, but I think I got the essence and I agree with you.
For context:
The project I'm working on is an integration of hardware and it's important to make it as convenient and safe for the customer as possible..
Thank you very much again! :)
Thank you! What made it stand out for me over other tutorials, is the handling of serialization, which often just isn't covered. Thanks!
Very helpful tutorial man! I'm pretty much new to Unity and just have gotten comfortable with the interface and all the coding, so now I'm looking into organizing my projects so that they are easier to work on. This video helps a lot with it:)
One of the best custom editor tutorial on youtube, thx..
cool tutorial . is so rare to find people that do tutorials about this stuff.
Exactly what I needed ! Thanks !
Glad to help Clément! I needed 8 tabs (at least!) for my "uPlatformer" Pack : )
Thank's for your tutorials. When I troubleshooting it is highly possible that your video will be as a result of searching for a solution. You saving my ass :D Thank you a lot!
Thank you for this tutorial!
You're welcome, glad it helps! I used this for my 'uPlatformer' asset on the Asset Store
Ill try and make this work whit scriptable Objects, thank you for this tutorial!
Thanks a lot xD
thank you
When I type something at the fields the inspector changes the current tab, help
Thank you very much!!!!!!!!!!!!
What if you want values in the custom editor to be initialized from code? In my case, I have some float fields initialized to some values in my code, but when I look at my custom editor they are all set to 0. I have to manually click on the gear icon and press Reset to see values from the code. Is there a solution?
Wow, you get a new suscriptor
Much thanks Samuel!
if i need to public scene,how can i do
it doesn't work as I expected. I write a string. I make a change to the code and the string disappears. How can i make it remember the strings even after code changes?
How can I replace tye text with images?
Hard to follow if you change the variables names on fly
that`s a good tutorial but what i want to know is how to resize the buttons in the inspector
PLEASE RESPOND! When I put an array in a tab, it does not allow me to open the array and assign elements. I tried everything. Can someone please tell me how to fix this??
yeah, i'd like to see how one could use arrays with this too
You can add the include children flag for the PropertyFiled.
In my case _doors is a list of transforms so I would have EditorGUILayout.PropertyField(_doors, true);
How did u create a 'line' below the tab tho ?
I think I used EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); answers.unity.com/questions/216584/horizontal-line.html
what happened to your patreon page?
Thanks for asking Jeff, I have deleted it during "Patreon Purge" lol but I am working on some Udemy courses and also considering full time employment doing Unity development. Some big changes coming! :) Thank you for the support!
@@RyanZehm What's your keywords on Udemy? I searched your name, but only has Ryan Kroonenburg, Ryan Dhungel and Drew Ryan.
I am new to Udemy so working on my first course for C# programming. I'll link to it once I get it finished. I'm interested to see if making Udemy courses is profitable work.