CodeSmile AssetDatabase 1.10
Unity's AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.
Loading...
Searching...
No Matches

◆ GetGuidAndFileId()

static ValueTuple< GUID, Int64 > GetGuidAndFileId ( [NotNull] Object asset)
static

Example usage:

var (guid, fileId) = Asset.GetGuidAndFileId(obj);
Parameters
assetObject from which GUID and FileId should be obtained.
Returns
The GUID and local File ID of the object. Returns an empty GUID and 0 if obj is null or not an asset.
See also

Definition at line 1009 of file Asset.File.cs.

1010 {
1011 if (asset == null)
1012 return (new GUID(), 0L);
1013
1014 // explicit variable + assign because TryGetGUIDAndLocalFileIdentifier has both an Int64 and an
1015 // Int32 overload on 2022.3.62f3 and only the Int64 form on 6000.6.0f1 and 6000.7.0a6; the
1016 // declared type selects the Int64 one
1017 var localId = Int64.MaxValue;
1018 return AssetDatabase.TryGetGUIDAndLocalFileIdentifier(asset, out var guid, out localId)
1019 ? (new GUID(guid), localId)
1020 : (new GUID(), 0L);
1021 }