CodeSmile AssetDatabase 1.9
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);
Replacement implementation for Unity's massive AssetDatabase class with a cleaner interface and more ...
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 947 of file Asset.File.cs.

948 {
949 if (asset == null)
950 return (new GUID(), 0L);
951
952 // explicit variable + assign because Unity 2021 has both long and int variants of the TryGetGUID* method
953 var localId = Int64.MaxValue;
954 return AssetDatabase.TryGetGUIDAndLocalFileIdentifier(asset, out var guid, out localId)
955 ? (new GUID(guid), localId)
956 : (new GUID(), 0L);
957 }