{"id":"illusionac/illusion-scalemanager","name":"illusion-scalemanager","scope":"illusionac","platform":"roblox","description":"A simple replacement for TextScaled that uses viewport width to control text size.","version":"1.0.0","latest":"1.0.0","versions":["1.0.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"aa24ba413db395ec3353cf05dfe34c4bfd1a710b4647bde32e107cb26009fed7","likes":0,"downloads":0,"install":"forest install illusionac/illusion-scalemanager","url":"https://forest.dev/p/roblox/illusionac/illusion-scalemanager","files":"https://api.forest.dev/ai/package/roblox/illusionac/illusion-scalemanager/files","readme":"# Illusion ScaleManager\r\n\r\nA simple replacement for `TextScaled` that uses viewport width to control text size.\r\n---\r\n\r\n## Overview\r\n\r\nThis module applies a `UIScale` to a `TextLabel` and updates it based on the camera’s viewport width.\r\nThe result is consistent, predictable scaling across different resolutions.\r\n\r\nUsing ISM, The Point of a TextLabel is **uniquely to display text**. It will have **NO** other purposes.\r\nThe Original Wish was that we could set a proper TextSize (pixels) on a Text, and it would scale for any screen resolutions.\r\nA TextLabel is **required** to be **placed** inside a **GuiObject container** with some properties set.\r\n**See Recommended Setup for more informations**\r\n\r\n---\r\n\r\n## Installation\r\n\r\n### Wally\r\n\r\nAdd `IllusionScaleManager` to your `wally.toml`:\r\n\r\n```toml\r\n[dependencies]\r\nIllusionScaleManager = \"illusionac/illusion-scalemanager@1.0.0\"\r\n```\r\n\r\nThen run `wally install` and require it from a **LocalScript**/**ClientScript**:\r\n\r\n```luau\r\nlocal ScaleManager = require(ReplicatedStorage.Packages.IllusionScaleManager)\r\n```\r\n\r\n### Manual / Rojo\r\n\r\n* Place `src/IllusionScaleManager.luau` in a `ModuleScript` (e.g. `ReplicatedStorage.Modules`), or build it with Rojo using `default.project.json`\r\n* Require it from a **LocalScript**/**ClientScript**\r\n\r\n```luau\r\nlocal ISM = require(\"@game/ReplicatedStorage/IllusionScaleManager\")\r\n```\r\n\r\n---\r\n\r\n## Usage\r\n\r\n```luau\r\nlocal ScaleManager = require(\"@game/ReplicatedStorage/IllusionScaleManager\")\r\n\r\nlocal label = script.Parent:WaitForChild(\"TextLabel\")\r\nlocal scaledText = ScaleManager.new(label)\r\n```\r\n\r\n### Example Usage (`CollectionService`)\r\n\r\nAn example client script is included in [ExampleUsage/init.client.luau](ExampleUsage/init.client.luau). It automatically initializes `IllusionScaleManager` on any `TextLabel` tagged with `\"SCALETEXT\"` via `CollectionService`, and cleans it up when the tag is removed.\r\n\r\n* Place `ExampleUsage/init.client.luau` in a `Script` inside `ReplicatedStorage` with `RunContext` set to `Client`\r\n* Place `src/IllusionScaleManager.luau` as a `ModuleScript` child of that script\r\n* Tag any `TextLabel` with `SCALETEXT`\r\n\r\n---\r\n\r\n## Studio Plugin (`AutoScaleText`)\r\n\r\nA Roblox Studio plugin is included in [StudioPlugin/init.plugin.luau](StudioPlugin/init.plugin.luau) to preview live text scaling in Studio edit mode for `TextLabel`s tagged with `\"SCALETEXT\"`.\r\n\r\n* Place `StudioPlugin/init.plugin.luau` in a `Script` (inside a folder) with `RunContext` set to `Plugin`\r\n* Place `src/IllusionScaleManager.luau` as a `ModuleScript` child of that script\r\n* Right-click the folder and select **Save / Export > Save as Local Plugin**\r\n* Use the **ToggleScaling** button in the **Scale Text** toolbar to enable or disable automatic scaling in Studio\r\n\r\n---\r\n\r\n## Base Width\r\n\r\nDefault is `1920`. use the BaseWidth property when calling the constructor to change it.\r\n\r\n```luau\r\nlocal scaledText = ScaleManager.new(label, 1366)\r\n```\r\n\r\nScaling is calculated as:\r\n\r\n```luau\r\nscale = viewportWidth / baseWidth\r\n```\r\n\r\n---\r\n\r\n## Cleanup\r\n\r\nHandled automatically when the `TextLabel` is destroyed.\r\n\r\nManual cleanup:\r\n\r\n```luau\r\nscaledText:Destroy()\r\n-- or by TextLabel reference:\r\nScaleManager.Destroy(label)\r\n```\r\n\r\n---\r\n\r\n## Notes\r\n\r\n* Client-only (uses `workspace.CurrentCamera`)\r\n* If a `UIScale` already exists, it will be reused but not destroyed\r\n* This module should be the only thing modifying `UIScale.Scale` on the label\r\n\r\n---\r\n\r\n## Recommended Setup For a TextLabel\r\n\r\nIMPORTANT: Make sure the TextLabel is Inside: A Frame, A TextButton...\r\nAlso (for TextButtons), you may remove the Text already set and put it to the Label.\r\nYou may not use TextWrapped. Adjust TextSize as you wish, it will scale !\r\n```lua\r\nSize = UDim2.new(0.5, 0, 0.5, 0)\r\nPosition = UDim2.new(0.5, 0, 0.5, 0)\r\nAnchorPoint = Vector2.new(0.5, 0.5)\r\nTextScaled = false\r\nBackgroundTransparency = 1\r\n```\r\n","readmeTruncated":false}