Struct AssetRef¶
Namespace: Apogee.Core.Assets
Assembly: Apogee.Core.dll
A reference to an asset by its path and its
The text form is res://models/car.glb|uid://4k2m9x7q1w3ze; a path alone and a UID alone (uid://4k2m9x7q1w3ze) are
also valid, and the empty text is the empty reference. | cannot be part of a path.
public readonly record struct AssetRef : IEquatable<AssetRef>
Implements¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors¶
AssetRef(string, AssetUid)¶
A reference to an asset by its path and its
The text form is res://models/car.glb|uid://4k2m9x7q1w3ze; a path alone and a UID alone (uid://4k2m9x7q1w3ze) are
also valid, and the empty text is the empty reference. | cannot be part of a path.
public AssetRef(string Path, AssetUid Uid)
Parameters¶
Path string
The path, such as res://models/car.glb or mod://id/a.png; empty (or null in default) when there is none.
Uid AssetUid
The UID, or
Fields¶
Separator¶
The character between the path and the UID in the text form.
public const char Separator = '|'
Field Value¶
Properties¶
HasPath¶
Whether there is a path.
public bool HasPath { get; }
Property Value¶
IsEmpty¶
Whether there is neither a path nor a UID.
public bool IsEmpty { get; }
Property Value¶
Path¶
The path, such as res://models/car.glb or mod://id/a.png; empty (or null in default) when there is none.
public string Path { get; init; }
Property Value¶
Uid¶
The UID, or
public AssetUid Uid { get; init; }
Property Value¶
Methods¶
FromPath(string)¶
A reference by path alone.
public static AssetRef FromPath(string path)
Parameters¶
path string
Returns¶
Exceptions¶
The path is empty, contains | or starts with uid:// (it would read back as a UID).
FromUid(AssetUid)¶
A reference by UID alone.
public static AssetRef FromUid(AssetUid uid)
Parameters¶
uid AssetUid
Returns¶
Parse(ReadOnlySpan<char>)¶
Reads the text form (see
public static AssetRef Parse(ReadOnlySpan<char> text)
Parameters¶
text ReadOnlySpan<char>
Returns¶
Exceptions¶
The text is not a valid asset reference.
ToString()¶
The text form: the path, path|uid://…, uid://… alone, or an empty string for the empty reference.
public override string ToString()
Returns¶
TryParse(ReadOnlySpan<char>, out AssetRef)¶
Reads the text form. Fails on a | with an empty path or an empty or invalid UID after it, on a second |, and on
text that starts with uid:// but is not a valid UID. The empty text is the empty reference.
public static bool TryParse(ReadOnlySpan<char> text, out AssetRef value)
Parameters¶
text ReadOnlySpan<char>
The text.
value AssetRef
The reference, or the empty reference on failure.
Returns¶
Whether the text was valid.