Add $uuid() template function for hyphenated UUIDs - #1534
Open
douglas-carmichael wants to merge 1 commit into
Open
Add $uuid() template function for hyphenated UUIDs#1534douglas-carmichael wants to merge 1 commit into
douglas-carmichael wants to merge 1 commit into
Conversation
$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(".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
$uuid()template function for hyphenated UUIDsFollow-up to #1533, where the unhyphenated output of
$uid()is listed as aknown limitation.
$uid(N)emits a v4-random id as 32 hex digits without hyphens — exactly whatUnity
.metaguids need — but some export formats require the canonicalhyphenated 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):$uid(N)for the same index, formatted as8-4-4-4-12 —
get_uid()already sets the version/variant bits, so the resultis a valid UUIDv4 (e.g.
babfc75f-178c-44e3-9ef5-89208122f156);process_uids()alongside$uid(); existing$uid()users areunaffected, and the two patterns cannot shadow each other since
"$uid("isnot 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 thatcaveat entirely — happy to update #1533 accordingly.