Scale UIStroke Objects & Limit Thickness with Minimum and Maximum Values

Scale your UIStroke objects and handle their boundaries easily.

Untitled (2)

Download Plugin

Updates
  • Support for light mode (Before: only dark)

Table of Contents
  • UIStroke
  • Plugin
    • Functionality
    • Scaling
    • Border
    • Caveats
    • Credits

Hello everyone! I’m here with a plugin that will make your interface flexible. This plugin helps you develop your games faster while using objects called UIStroke.

UIStroke

It was fully implemented in September 2021. Really comes in handy when you lack outlines to your interface; UIStroke comes into play.

UIStroke, whose Thickness property is responsible for carrying the number, calculates the outline in pixels. It doesn’t have a specific property just like how GuiObject objects have a Scale sub-property. Hence the plugin.

Plugin

Install the plugin on Studio. A LocalScript will be automatically added in ReplicatedFirst in order for thickness to be properly adjusted. Unless you delete or rename that script, it will function with no flaw. If an update arrives, the script will be updated automatically.

This is the start widget:

  1. Prompts scaling frame for all UIStroke objects available.
  2. Prompts adjusting maximum/minimum thickness frame for all UIStroke objects available.
  3. Redirects to info frame.
  4. Allows UIStroke objects to be set up one by one.

Functionality

Works with all UIStroke objects. All you need to do is put your UIStroke objects beneath a rendered frame in order for the plugin to calculate the desired scale. If not done so, the plugin will leave a warning in the output for those objects that require manual updates.

Scaling

This is done in two different ways. First, LowerScale is determined by the dimension that is smaller in size than the other component; second, UpperScale is determined by the one larger.

For instance, if you choose LowerScale for one UIStroke, its thickness will be reliant on the Y-dimension -if GuiObject is horizontally larger. On the contrary, if you choose UpperScale, X-dimension will decide.

The formula to calculate the scale:

scale = UIStroke.Thickness / currentCamera.ViewportSize.X

The current viewport size matters. If you had your UIStroke thickness at the desired pixels in accordance with your studio resolution, you’re good to go to press the scale button.

Border

Of course, you may experience not-so-good results while your UIStroke is scaled. For other reasons as well, you could limit the thickness. You can set the minimum and maximum pixels of thickness used in-game to force-update the thickness property.

Caveats

  • Some UIStroke objects may require manual adjustments.
  • Consider the viewport size as it’s a factor in determining the scale.
  • Testplay your game to check whether UIStroke objects work as anticipated.

Credits

@Dekkonot’s Instance Serializer plugin


I’m ending up this thread by demonstrating the plugin and linking the Github repository for those curious to glance at the code. Comment down if you have any questions, please. See you all, I hope you enjoyed my resource!

2 Likes

This would certainly be a convenient Plugin for accurately adjusting UIStroke to a suitable level for a UI in-game! Will try this Plugin out when I get access to Studio! :wink:

1 Like