Improve Your Workflow with Custom Property Drawers & UI Toolkit | Unity Tutorial

Sdílet
Vložit
  • čas přidán 12. 09. 2024

Komentáře • 35

  • @samyam
    @samyam Před rokem +10

    thanks for featuring my "who, me?" 😀

    • @LlamAcademy
      @LlamAcademy  Před rokem +2

      Thanks for sending such a great one!

  • @NaviYT
    @NaviYT Před rokem +2

    I like the slightly less playful approach in this video. I especially loved the beginning where you gave a real world scenario. Thank you for spreading information that otherwise would require months of research and development :)

  • @dreamisover9813
    @dreamisover9813 Před rokem +2

    I've never seen the bind property approach, interesting!

  • @Bananenbauer123
    @Bananenbauer123 Před rokem +2

    This is a really nice tutorial. It's pretty difficult to get better sources on your hand for utilizing the UI Toolkit. I've tried making something similar to what was shown in the video utilizing uxml files instead, but the issue is that I couldn't figure out how to properly setup multiple nested classes/properties to be shown in my custom inspector.
    Once you go deeper than 1 layer for showing serialized properties, it seems kind of mandatory to do this stuff on the C# side of things.
    Kind of a shame really, I don't necessarily enjoy doing layout stuff in C# code. The goal of this new web-design oriented approach was to seperate layout, style and logic, but it seems UI toolkit isn't quite there yet. The C# code can get pretty verbose.
    Either way, thanks a lot, this is the most up to date tutorial I could find, everyone else seems to be using IMGUI.

  • @chriss8096
    @chriss8096 Před rokem

    I really think you should include this video in your gun scriptable objects tutorial.. As I was following along, i got a bit stuck on how to replicate the editor displayed to the degree you did, which isn't what i wanted to do, but learn HOW you did it. Searching through videos, I found this one. For me, this helps piece together the end of video 8 in that series. Your tutorials are really helpful in understanding what, how and why to do certain things. Its surprising your videos don't have more views.

    • @LlamAcademy
      @LlamAcademy  Před rokem

      Thank you for the feedback. I will be sure to link to this one directly from that video to help people find it more easily

  • @TheRoarer
    @TheRoarer Před rokem +1

    SAM CAMEO! OH MAN, THAT GOT ME HYPED! Two of my favorite unity teachers in one video.

  • @i.k4854
    @i.k4854 Před rokem +1

    Looks greate. Will definitivly try to use it.

  • @Bobster536
    @Bobster536 Před 4 měsíci

    i feel hopeless, AddToClassList("align-horizontal") doesnt work for me, neither does RegisterCallback(). Using property drawer for my serializable pure c# class, that is displayed as an array ellement of a scriptable object. The titleContainer displays elements vertically and doesnt respond to clicks. Other than that everything works as shown in the video.

  • @XadegamerOfficial
    @XadegamerOfficial Před rokem +1

    Awesome

  • @startsmart211
    @startsmart211 Před rokem +1

    Bro I need your help . Please tell me or make a video about how to keep game alive in background made from unity. Beacuse I am stop here only. When I am playing game and I pressed home button on phone and after some time when I want to resume my game then it doesn`t resume , it restart . So tell me how to deal with this problem because I am not getting any solution from google or youtube. Other games made from unity that have ability to resume game from where player left . So please tell me or make a video on this Topic.
    Thanks In Advance.

    • @LlamAcademy
      @LlamAcademy  Před rokem

      On Android I think this is usually due to it being unloaded in memory. My game does the same if you don't use it for a long period of time, but when coming back in shortly after going away, it resumes where it left off. Didn't play with it too much on iOS to see if it had the same behavior

  • @williamli401
    @williamli401 Před rokem

    I'm new to Editor scripting, and I don't really understand the RegisterValueChangedCallback, and there isn't a lot of documentation. Could you explain to me how this works? Thanks for the tutorial!
    Edit: Specifically, could you explain why you call BuildUI() in the RegistValueChangedCallback? What does this do? When I test it it just clears my PropertyDrawer and does nothing afterwards until I reload the inspector.

    • @LlamAcademy
      @LlamAcademy  Před rokem

      Sure. RegisterValueChangedCallback is a callback that is called when the value of the object field's value (or any other field really) detects a change. It was important to do here because UI Toolkit does not work the same as IMGUI / the old UI way where it updates every frame. UI Toolkit only updates when necessary, which makes it much more performant.
      When the user (us) changes from one scriptable object to another, I wanted all of the values to reflect on the inspector. That's why we are listening to this event. The most convenient way to do that, since we already have written all the code to create the UI, was to just clear everything and re-add it.
      If you're getting in the inspector after calling BuildUI() again, you might want to debug it to see why the second call to BuildUI isn't adding everything back to the content panel. Perhaps there's a small difference in a condition that's failing. The full project is available on GitHub for free if you wanted to compare your implementation to what I have: github.com/llamacademy/scriptable-object-based-guns/tree/ui-toolkit-editor
      Just in case you didn't find the documentation page, it's here: docs.unity3d.com/2020.3/Documentation/Manual/UIE-Change-Events.html

    • @williamli401
      @williamli401 Před rokem

      How does calling BuildUI again add anything to the inspector? Does it not just return a value we never read? Ive added a Debig.Logstatement into the BuildUI and it always shows in the console, so the function is being called, so I dont think this is the problem.

    • @LlamAcademy
      @LlamAcademy  Před rokem

      @@williamli401 Within BuilUI() it is constructing a bunch of elements to display and adding them to the RootElement. This is how the UI system understands that it needs to redraw. Calling Clear() removes all elements, then within BuildUI() we are adding new instances of all of these elements once more.

    • @williamli401
      @williamli401 Před rokem +1

      ​@@LlamAcademy Oh I see so using Add() adds it to the original inspector, which we passed into BuildUI() as a reference and not a value, and the return value of BuildUI() is actually the original inspector. Thank you for answering my questions!

    • @LlamAcademy
      @LlamAcademy  Před rokem

      Happy to answer them! Sorry I didn’t make that part super clear in the video. Happy editor scripting!

  • @redragon1229
    @redragon1229 Před rokem

    There's also free Tri-Inspector and Markup-Attributes besides Odin

  • @AmgedAlfakih
    @AmgedAlfakih Před rokem

    Hello sir, are we able to do mix between the automatically generated inspector from ui builder and the manually written code in the same script?, cause I've gathered all of scriptable object in one large script, and it'll be a headache if i want to make it as you

    • @LlamAcademy
      @LlamAcademy  Před rokem

      If you want to use the default inspector you can just group the variables together and use things like [Header], [SerializeField], and [Range] attributes to get similar results with much less work.

    • @AmgedAlfakih
      @AmgedAlfakih Před rokem

      @@LlamAcademy why when i edit the style in the code it work well when I'm selecting the gun editor, but the moment i select another inspector and go back to the gun inspector the style reset to the default, like i didn't do anything

  • @raifazhar9727
    @raifazhar9727 Před 6 měsíci

    why my property drawer script not using root.uss script

    • @LlamAcademy
      @LlamAcademy  Před 6 měsíci

      On your UXML you have to add it at the top right of the UI Builder as a supported style sheet

    • @raifazhar9727
      @raifazhar9727 Před 6 měsíci

      I added it but it did not work. I am doing the same thing as you did in the video created a c# script with base class property drawer and had a root.uss file that contain all the uss in it. But when I used inspector.AddToClassList("panel"); the editor of scriptable did not change. like I can see all the text and button but the css of flex-direction: row is not working. @@LlamAcademy

    • @raifazhar9727
      @raifazhar9727 Před 6 měsíci

      okay its working. I did not know that you have to setup some Uxml also.

  • @ronan5946
    @ronan5946 Před rokem

    Oh man, it sucks that now that I am mastering IMGUI and create good custom inspectors, Unity comes up with a disgusting Web Based UI System. One of the reasons I gave up on web development is this CSS, XML based work. It sucks.

    • @LlamAcademy
      @LlamAcademy  Před rokem +1

      If you really like the IMGUI workflow, you can still have largely the same workflow with UI Toolkit.
      You can assign styles in code instead of with USS, create all UI elements with code, and not ever touch the UI Builder, UXML or USS files.
      The layout system is somewhat different so that will take a little getting used to from IMGUI, but your overall workflow should remain relatively unchanged!

  • @haim96
    @haim96 Před rokem

    instead of fast explain complex code you should demonstrate something from scratch. it will be much more useful...

    • @LlamAcademy
      @LlamAcademy  Před rokem +2

      Thanks for the feedback. Usually, I prefer to write it all out in the video. I agree it feels easier to follow that way.
      Since this was largely following the same pattern repeatedly and was a pretty large amount of code, I thought I would try this format. I appreciate you letting me know that didn't work very well for you.