Search Unity

Feature Request Easier to extend elements

Discussion in 'UI Toolkit' started by Leslie-Young, Jun 10, 2021.

  1. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    UI Toolkit is really awesome so far but I do hit a lot of blockers because of members marked internal or private when i am trying to extend on it an existing element. This is mostly because I am working on runtime UI rather than editor side UI.

    I'd like if you would go through the controls made so far and look at where they could be opened up more. I'll use the Slider as example but there are other.

    I am simply trying to add a fill effect to its track. So from the left up to where the dragger element is would be a fill and to the right the normal track background colour.

    I thought I'd derive a new class from Slider and then add my fill element in the constructor to the track element. That worked fine but next I need to figure out how to actually update the fill. It would have been so much easier if I could simply override UpdateDragElementPosition() and then just call base.UpdateDragElementPosition() before doing the fill's update calculations.

    I dunno, maybe i am just asking for things that can easily be done and I'm just not seeing the solution or there are good reasons for all these members marked as internal or private or not virtual.

    Back to figuring out how to do the update on the fill before I have to copy all the source of BaseSlider and Slider to spin my own version :s

    [edit] I ended up registering a Value Changed callback, which works fine. So I guess what I am asking for is pointless when one look at a solution like that.
     
    Last edited: Jun 10, 2021
    FWCorey likes this.
  2. griendeau_unity

    griendeau_unity

    Unity Technologies

    Joined:
    Aug 25, 2020
    Posts:
    248
    I'm glad you found the way to go!

    Like you said at the end, most of the time, things are possible to do in other ways because UI Toolkit is pretty extensible through Queries, Event, Styling, etc. We often keep things internal/private because it is easier for us to make changes afterwards without having to change the public API.
    That being said, it's not a bad thing to let us know when something internal or private would be useful for users. We want to know how we can improve/simplify your work!