Over the past few days I’ve been trying to create and organize code for UI in a way that’s easily scalable but I just can’t get it right. My goal is to be able to just create the UI, put it inside StarterGui and then just tweak a few things inside a script in order for it to work. I’ve only gotten this to work for one thing so far, and that is for defining the colors of the UI for different themes (like light mode and dark mode).
The problem is that most of the UI elements have different functionality. If I try to make the code more organized and easier to work on, I end up losing a lot of granularity, but if I try to make it work as intended the entire structure goes haywire and changing/updating things quickly becomes hell. At that point, I might as well have a script under each UI element
In short, I can’t think of a way to properly structure UI for script without losing out on a ton of granularity.
On a more serious note, the approach I have ended up taking is making a sort of UI framework system (mostly for more complex ui elements, ie integrating ui shadows with the 9-slide thing, but having it as a simple component on which you can adjust the radius. Or a scrolling frame where the scroll distance is adjustable, or can be scrolled by a script. Also making a theme system, custom mouse enter and mouse leave events, and stuff… ) but this is a bit extreme. Something that is useful is making what I call “prefabs”, stuff like sliders, dropdowns, or even buttons, scrolling frame, or whatever, built with a cohesive style. I’ve found that components tend to keep granularity as you still build the ui “manually”, but you have some shortcuts for common stuff
This I would refer probably as the nuclear option
Another option is to submit to the ui, and make a 3k lines of code script. Actually not too bad. Ui code is quite repetitive, so it can be a mess, and kinda be fine. It isn’t some complicated system. But it will be painful (war is always painful)
What I have right now is very similar in style to the theme system and mouse enter/leave stuff. I think I’ll just have to suck it up and go to war by building things manually (I’ll leave the post open for now in case anyone else wants to share their approach)
Listen to what others have to say. I’ve done ui out of necessity, it’s not something I like doing. I’ve always preferred making UI through scripts, I have tried making templates, wasn’t really better, but I do know someone that is really good at making UI using the studio tools. Don’t know how he organizes the scripts and functionality for the UI though. I’ve ended up going for the nuclear option lol, fully scripted UI with a framework type of thing