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!

Комментарии • 35

  • @AlexTuduran
    @AlexTuduran 5 лет назад +23

    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?".

    • @michaelmenzi8334
      @michaelmenzi8334 3 года назад +1

      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!)

    • @AlexTuduran
      @AlexTuduran 3 года назад +1

      @@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.

    • @michaelmenzi8334
      @michaelmenzi8334 3 года назад

      @@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! :)

  • @michaelmenzi8334
    @michaelmenzi8334 3 года назад +1

    Thank you! What made it stand out for me over other tutorials, is the handling of serialization, which often just isn't covered. Thanks!

  • @simonspasskiy
    @simonspasskiy 4 года назад +1

    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:)

  • @Ahmet-wt8ng
    @Ahmet-wt8ng 4 года назад +1

    One of the best custom editor tutorial on youtube, thx..

  • @fokozuynen2048
    @fokozuynen2048 2 года назад

    cool tutorial . is so rare to find people that do tutorials about this stuff.

  • @TheKassaK
    @TheKassaK 6 лет назад +2

    Exactly what I needed ! Thanks !

    • @RyanZehm
      @RyanZehm  6 лет назад

      Glad to help Clément! I needed 8 tabs (at least!) for my "uPlatformer" Pack : )

  • @QuakiTutua
    @QuakiTutua 4 года назад +1

    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!

  • @VilleJaako
    @VilleJaako 6 лет назад +1

    Thank you for this tutorial!

    • @RyanZehm
      @RyanZehm  6 лет назад

      You're welcome, glad it helps! I used this for my 'uPlatformer' asset on the Asset Store

  • @IkeVoodoo
    @IkeVoodoo 4 года назад +1

    Ill try and make this work whit scriptable Objects, thank you for this tutorial!

  • @douglasciole487
    @douglasciole487 6 лет назад +1

    Thanks a lot xD

  • @user-ou5qg1kc9x
    @user-ou5qg1kc9x 2 года назад +1

    thank you

  • @onnyor
    @onnyor 6 лет назад

    When I type something at the fields the inspector changes the current tab, help

  • @ELDAN_
    @ELDAN_ 3 года назад

    Thank you very much!!!!!!!!!!!!

  • @melchiah4925
    @melchiah4925 5 лет назад

    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?

  • @samueldiazreyes7385
    @samueldiazreyes7385 6 лет назад +1

    Wow, you get a new suscriptor

    • @RyanZehm
      @RyanZehm  6 лет назад

      Much thanks Samuel!

  • @redinternet9893
    @redinternet9893 6 лет назад

    if i need to public scene,how can i do

  • @Imperial_Dynamics
    @Imperial_Dynamics 5 лет назад

    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?

  • @arsylgames
    @arsylgames 4 года назад

    How can I replace tye text with images?

  • @WalterRDK
    @WalterRDK 4 года назад

    Hard to follow if you change the variables names on fly

  • @DumbTanuki
    @DumbTanuki 6 лет назад

    that`s a good tutorial but what i want to know is how to resize the buttons in the inspector

  • @legochronicles1731
    @legochronicles1731 5 лет назад

    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??

    • @Imperial_Dynamics
      @Imperial_Dynamics 5 лет назад

      yeah, i'd like to see how one could use arrays with this too

    • @celinedrules
      @celinedrules 4 года назад

      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);

  • @benayamanuel
    @benayamanuel 3 года назад +1

    How did u create a 'line' below the tab tho ?

    • @RyanZehm
      @RyanZehm  3 года назад

      I think I used EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); answers.unity.com/questions/216584/horizontal-line.html

  • @jeffwang2216
    @jeffwang2216 5 лет назад +1

    what happened to your patreon page?

    • @RyanZehm
      @RyanZehm  5 лет назад

      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!

    • @jeffwang2216
      @jeffwang2216 5 лет назад

      @@RyanZehm What's your keywords on Udemy? I searched your name, but only has Ryan Kroonenburg, Ryan Dhungel and Drew Ryan.

    • @RyanZehm
      @RyanZehm  5 лет назад

      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.