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

◆ GetGuid()

static GUID GetGuid ( [NotNull] Object asset)
static

Returns the GUID of an object. Returns an empty GUID if the object is null or not an asset.

Parameters
assetAn asset instance.
Returns
The GUID of the asset. Returns empty GUID if the asset is null or not an asset.
See also

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

1035 {
1036 if (asset == null)
1037 return new GUID();
1038
1039 // explicit variable + assign because TryGetGUIDAndLocalFileIdentifier has both an Int64 and an
1040 // Int32 overload on 2022.3.62f3 and only the Int64 form on 6000.6.0f1 and 6000.7.0a6; the
1041 // declared type selects the Int64 one
1042 var localId = Int64.MaxValue;
1043 return AssetDatabase.TryGetGUIDAndLocalFileIdentifier(asset, out var guid, out localId)
1044 ? new GUID(guid)
1045 : new GUID();
1046 }