UGTK / Toolkit / Utility Systems / Web Param System Completed
Web Param System
Summary
Reads query (?id=abc) and hash (#token=xyz) parameters from the page URL (WebGL Application.absoluteURL) and dispatches each value to a per-parameter UnityEvent, with an editor test URL for simulating parameters outside WebGL.
Content
Modules Dependencies
This module has no hard UGTK dependencies.
Setup
Drop the WebParam prefab into the scene — a GameObject with Mn_WebParam ready to configure:
Or add the Mn_WebParam component to a GameObject. Add one Binding per parameter you expect (set Variable Name, e.g. id, and wire its onValue(string) event). Configure the parsing options (Case Insensitive Names, Prefer Last Value On Duplicates, Url Decode Values, Also Read Hash Fragment) and, for editing/testing, enable Editor Test Url and set an editorTestUrl such as https://example.com/?id=abc&mode=dev#token=XYZ. Leave Auto Read On Start on to parse automatically in Start().
How To Use
On WebGL, opening .../index.html?id=ABC invokes the id binding's event with "ABC". In the editor/standalone the editorTestUrl is used instead (no network request).
ReadAndDispatch(): manually re-parse the current URL and fire the events.TryGetValue(name, out value): read the last parsed value for a parameter.AddRuntimeListener(name, action)/RemoveRuntimeListener(name, action): attach/detachUnityAction<string>handlers at runtime (a binding is created if missing).- Outcome events:
onAnyVariableInUrl/onNoVariablesInUrl,onBindingFound(string)/onBindingMissing(string)per declared binding, andonReadCompleteafter each parse.
The static ParseUrlParams(url, includeHash, urlDecode, preferLast, caseInsensitive) can parse any URL into a key/value dictionary. A key without = is treated as the flag value "true".
Good to know:
- Only WebGL has a real URL. Everywhere else
Application.absoluteURLis empty, which is whyeditorTestUrlexists: test the whole flow in the editor, then trust the build. Remember to turnEditor Test Urloff — or at least to keep it harmless — before shipping. - The hash fragment never reaches the server.
#token=XYZis client-side only: it is the right place for something you do not want in the web server logs, and the wrong place for something the backend must see. - A parameter that is not in the URL fires
onBindingMissing, notonValue. Handle it, or a missing parameter will look like "nothing happened". - Never trust these values. A query string is fully under the player's control: use it to select a language, a table id or a demo mode — never to grant something.
TryGetValuereads the last parse: callReadAndDispatch()first if the URL may have changed (single-page navigation).
Testing Scene
Open WebParamScene in the module's Debug/ folder and select WebParam. The
Editor Test Tools block at the bottom of the inspector does the whole thing with the editor
stopped: no WebGL build, no upload, no address bar.
What to do, in order:
- Paste a URL into Test URL and press Parse the URL. The block lists every parameter it read.
- Dispatch it and watch the bindings fire.
- Remove one parameter from the URL and dispatch again.
- Try a parameter in the hash fragment rather than the query string.
Step 3 is the silent failure this system produces: a binding whose parameter is absent simply never fires, with nothing in the console. The inspector lists those bindings before you dispatch. All of this works without a WebGL build, which is the point — otherwise testing a binding means building, uploading and opening a link.
Technical Info
- Mn_WebParam: MonoBehaviour that resolves the effective URL (real
Application.absoluteURLon WebGL, the test URL elsewhere), parses query and hash parameters, dispatches values to the matching bindings, and raises the outcome events. Includes the static URL-parsing helpers and theParamBindingstruct. - ReadOnlyInInspectorAttribute / ReadOnlyInInspectorDrawer: Internal helper attribute and drawer used to show the read-only
Last Call Was Startfield.
© 2026 Marcello De Bonis. All rights reserved
Depends on 0
- Standalone: no other module required.
Used by 1
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 0 modules in total.
UGTKengine within an engine


