Skip to content

Add $uuid() template function for hyphenated UUIDs - #1534

Open
douglas-carmichael wants to merge 1 commit into
RodZill4:masterfrom
douglas-carmichael:add-uuid-template-function
Open

Add $uuid() template function for hyphenated UUIDs#1534
douglas-carmichael wants to merge 1 commit into
RodZill4:masterfrom
douglas-carmichael:add-uuid-template-function

Conversation

@douglas-carmichael

Copy link
Copy Markdown

$uuid() template function for hyphenated UUIDs

Follow-up to #1533, where the unhyphenated output of $uid() is listed as a
known limitation.

$uid(N) emits a v4-random id as 32 hex digits without hyphens — exactly what
Unity .meta guids need — but some export formats require the canonical
hyphenated UUID form; the manifest of Imaginando VS 2 shaders is one example.
The hyphenated form cannot currently be produced inside a template.

This adds $uuid(N):

  • returns the same cached id as $uid(N) for the same index, formatted as
    8-4-4-4-12 — get_uid() already sets the version/variant bits, so the result
    is a valid UUIDv4 (e.g. babfc75f-178c-44e3-9ef5-89208122f156);
  • processed in process_uids() alongside $uid(); existing $uid() users are
    unaffected, and the two patterns cannot shadow each other since "$uid(" is
    not a substring of "$uuid(".

If this lands together with #1533, the Imaginando VS 2 target's manifest line
can switch from "uuid": "$uid(0)" to "uuid": "$uuid(0)", removing that
caveat entirely — happy to update #1533 accordingly.

$uid(N) emits a v4-random id as 32 hex digits without hyphens, which is
what Unity .meta guids need, but some export formats require the
canonical hyphenated UUID form (e.g. the manifest of Imaginando VS 2
shaders, see RodZill4#1533).

$uuid(N) returns the same cached id as $uid(N) for the same index, in
8-4-4-4-12 hyphenated form (the version/variant bits set by get_uid()
already make it a valid UUIDv4). Existing $uid() users are unaffected,
and the two patterns cannot be confused by the regexes since "$uid("
is not a substring of "$uuid(".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant