Closed krypto5863 closed 2 years ago
Not sure exactly what you mean, could you provide code examples of the issue and what you did to solve it?
I assume you're talking about PanelBase
here. The root object has a VerticalLayoutGroup
with forceExpandWidth/Height
and childControlWidth/Height
all true
. The ContentRoot has the same but with forceExpandWidth/Height
set to false.
Changing this dramatically would probably break all current implementations of PanelBase
in existing mods, so I'd be hesitant to change this too much, especially since it seems to work fine for pretty much all use cases other than your specific one here.
Yeah, i'm inheriting PanelBase
and doing stuff, but I'm relying on the base implementations of the title bars and panels. My solution was as follows:
UIFactory.SetLayoutElement(ContentRoot, 0, 0, flexibleWidth: 9999, flexibleHeight: 9999);
This prevents the following issue where the button is adhering to the minimum width of the panel which causes flexible elements to be too large and cut off, this issue doesn't afflict UIs that are larger than the minimum:
As you'll notice, the close button on the title bar is also missing in the image above, that's because of the following minimum width in this line of code: https://github.com/sinai-dev/UniverseLib/blob/f8580ece8aec2df87c2872350695c8d72ea3bc7d/src/UI/Panels/PanelBase.cs#L145
Something which I also resolved by doing: UIFactory.SetLayoutElement(titleTxt.gameObject, 50, 25, 9999, 0);
Though honestly I could've just omitted the minimum width entirely but I figure it'd be counter-intuitive.
Results of my fixes are as follows: The buttons properly adjust to the widths of the UI, even down to more absurd degrees.
My suggestion is just to make less use of minimums like the following, groups and their properties shouldn't need to be changed in a meaningful way, and to rely more on flexible spaces that scale better.
Oh one last thing I wanted to mention though this one I'm not sure about. By default the scrollview comes with a width of 0 and height of 0 which causes it to be basically invisible within my panel. I fixed that also by doing the following:
var ScrollView = UIFactory.CreateScrollView(ContentRoot, "DirectoryViewer", out directoryGroup, out var scrollBar, smokedGlass);
UIFactory.SetLayoutElement(ScrollView, flexibleHeight: 9999, flexibleWidth: 9999);
I'm not sure if this is a problem caused by something else? But I just wanted to point that out since I believe that by default this should probably already be set if it isn't.
Also as a suggestion, a generic version of the tree view in UnityExplorer for UniverseLib would be pretty darn great to have.
Thanks for the detailed explanation. I implemented your changes and it doesn't seem to cause any issues with UnityExplorer or my Config Managers, so I'd be happy to add them.
By default the scrollview comes with a width of 0 and height of 0 which causes it to be basically invisible within my panel.
Yeah you're probably right, for the ScrollView at least you pretty much always want it to take the maximum available size under the parent, so we may as well just add the LayoutElement from UIFactory when we create it.
For other elements I think you'll likely encounter the same issue, pretty sure that's the case with Buttons and Labels too. I figure you pretty much always want to set your own values to the LayoutElement for those types of controls though which is why I didn't waste time adding it from UIFactory.
Also as a suggestion, a generic version of the tree view in UnityExplorer for UniverseLib would be pretty darn great to have.
Sure I can look into that.
https://github.com/sinai-dev/UniverseLib/releases/tag/1.3.4
Hopefully this fixes your issues!
edit: had a few more things I needed to add after that release, we're now on 1.3.5: https://github.com/sinai-dev/UniverseLib/releases/tag/1.3.5
Was building a small UI for a simple plugin and noticed my button was stretching way out of bounds when using flexible spaces. Eventually I set a LayoutElement on the contentRoot and omitted minimums but set flexible spaces to max and this resolved it, (title bar was still acting as before though, guessing because the label or whatever holds the label has a high minimum)
Figure this isn't intended, but would be nice if this wasn't an issue when working with small panels. Though honestly space friendly minimums and intelligent use of flexible spaces by default would make this library much easier to use imo.