Is there any definitive upper limit to the slate scrollbox? I have been able to populate it with 20,000 widgets (simple button with text and just text tested) but when I push it to say 50,000 widgets I start experiencing frame lag and delayed load time. I’m trying to create an extremely dynamic offline/online user browser system in game. I did read somewhere this could be style-related but I have yet to test that theory as I’m currently at work so I figured I’d seek some experienced advice in the meantime. Is an endless list of widgets in a scrollbox even possible? Or is it just a pipedream?
Mind the double post…
But I’ve also tried to constrain the height to no avail, it behaves as if its rendering all 50,000 widgets which are hidden by the scroll.
50,000 child widgets is crazy talk IMO. Even if they aren’t rendered, they still have to be checked every frame for ordering and visibility calculations. That’s A LOT of iteration for no real purpose.
If you want a “limitless” list, you probably want to take a window approach where you have, let’s say, 20 widgets (and only ever 20), and you simply change the data they are pointing at based on where the user is scrolling (if they are looking at entries 1 - 20, 40 - 60, etc, the widgets never change, you are just dynamically updating which data entry each widget points to). You’d need to overload the scrolling logic to move your internal data window, but that’s all.
I like that concept and that’s pretty much what I needed to hear, I figured that would have to be the best approach. Let me then ask you this, you think I’d be able to delete each widget as it is scrolled by (Get Scroll Offset) and increase/decrease the height of a top/bottom widget to make it emulate the populated space?
That way I could get away with using the default scrollbox versus wasting way more time recreating it.
I don’t think you can add/remove widgets to the scroll box and get your desired behavior since the scroll box’s internal scrollbar will check to see how many widgets it has vs how many it can place on screen to determine what the max scroll limits are and which widgets are in view.
So, instead of a scrollbox you’d just use:
- Horizontal Box (for the layout of your entries + scrollbar)
- Vertical Box (with all your entries contained within which use functions to pull their data based on the current scroll parameters).
- Vertical Scrollbar (with the various scrolling min/max/view methods overriden)
You could look at the code of the Scrollbox to give you some help on how to set everything up, but I don’t think you can use it for this particular feature.
So, with this method I’d also be able to rebuild the list on the fly dynamically, correct? Alphabetical order and what not? Thanks for the advice, I’ll look into it for the resizing of the scrollbar dynamically and correlate it with MY list size.
Yea, sure. As long as you are using functions/dynamic getters rather than hard coding data - it can be organized however you wish. Again, you aren’t actually changing the widgets - merely what they are showing based on whichever parameters you want.
Hey man I just realized you were the same person I was speaking to on my current post, and not to resurrect old threads but this is very relevant. I’m attempting this now (Was without a PC for a few months) and I’m trying to figure out how to make SScrollBar actually move (Currently it’s setup as you previously suggested precisely) as it will not move at all, I figured it would at least, does this have to be hard coded manually as well? Can you provide any help on how to override the scrolling logic? I’ll keep tinkering otherwise. Thanks man.
Bump to keep relevant
You would have to manually set/update the scrollbar via SScrollBar::SetState(…), and hook into the SScrollBar::OnUserScrolled(…).
SetState will set the position of the scroll and the size of the “thumbnail” (the small widget that represents the scroll position), so figure out where your scroll is on a scale of 0 - 1 and pass that in.
OnUserScrolled will tell you where where the widget is (again, on a scale of 0 - 1).
Hey super appreciated man, I’ll give this a try and update accordingly, I’m sure I’ll end up hitting some road block again in the future. Those functions are EXACTLY what I was looking for, just had trouble deciphering them amongst all the others, documentation is so vague.
Using
UPROPERTY(EditAnywhere, BlueprintReadWrite)
SScrollBar ScrollBar;
in the .h
and
ScrollBar = SNew(SScrollBar)
in the .cpp
failing to compile?
I know I’m doing something dumb here
"Severity Code Description Project File Line
Error C2679 binary ‘=’: no operator found which takes a right-hand operand of type ‘TSharedRef<ObjectType,0>’ (or there is no acceptable conversion) "
TSharedRef< SScrollBar > MyScrollBar;
MyScrollBar = SNew(SScrollBar).OnUserScrolled(this, &MyObject::OnUserScrolled);
You need to store the SScrollBar as a pointer, or shared ptr/ref. I’m not sure if you can expose them through the normal UPROPERTY flags.
Where exactly am I supposed to pop “TSharedRef< SScrollBar > MyScrollBar;” in? Everywhere I put it results in compilation failure, also “&MyObject” = ?
Sorry for all the noob questions, mad appreciated.
Tried just about everywhere .cpp and .h
Found solution
TSharedRef<SScrollBar> MyScrollBar = SNew(SScrollBar);
Still not having luck without doing that though and still no luck WITH, this is the error with your provided code
see reference to function template instantiation ‘TSharedRef<ObjectType,0>::TSharedRef(void)’ being compiled
2> with
2>
2> ObjectType=SScrollBar
Definitely hitting a solid road block again. Just not connecting the puzzle.
You’d define it in the header file.
Just search the code for SScrollBar and you’ll find plenty of examples to look at.
Hey man just figured I’d update you
The solution I conjured up in combination with your’s ended up being the answer to this problem.
Through a lot of trial and error I figured out how to dynamically change the SScrollBar’s position and from that I can basically do everything else. That 3 months of no GPU really made me mad rusty but I’m starting to grease the gears and learn what I’m doing again. I’ll throw another post up if I have any more issues, you tha man.
.h
TSharedRef<SScrollBar> MyScrollBar = SNew(SScrollBar);
.cpp
MyScrollBar->SetState(0.2, 0.2);
Then to actually get it to appear in slate
SNew(SBorder)
MyScrollBar
]
Now that I got that tested and working, I’ve been reading into the ScrollBar & Box source codes and still not really quite figuring out exactly what I have to do to hook into the SScrollBar::OnUserScrolled() function. You think you could point me in the right direction to being able to change these variables dynamically? Not figuring out how to begin the click detection on the scrollbar and the Y-Axis movement to make it go up and down, ect.