Exemplo n.º 1
0
        internal static Hash128 GetArtifactHash(string guid, Type importerType, ImportMode mode)
        {
            switch (mode)
            {
#if UNITY_2020_2_OR_NEWER
            case ImportMode.Asynchronous:
                return(AssetDatabaseExperimental.ProduceArtifactAsync(new ArtifactKey(new GUID(guid), importerType)).value);

            case ImportMode.Synchronous:
                return(AssetDatabaseExperimental.ProduceArtifact(new ArtifactKey(new GUID(guid), importerType)).value);

            case ImportMode.NoImport:
                return(AssetDatabaseExperimental.LookupArtifact(new ArtifactKey(new GUID(guid), importerType)).value);
#else
            case ImportMode.Asynchronous:
                return(AssetDatabaseExperimental.GetArtifactHash(guid, importerType, AssetDatabaseExperimental.ImportSyncMode.Queue));

            case ImportMode.Synchronous:
                return(AssetDatabaseExperimental.GetArtifactHash(guid, importerType));

            case ImportMode.NoImport:
                return(AssetDatabaseExperimental.GetArtifactHash(guid, importerType, AssetDatabaseExperimental.ImportSyncMode.Poll));
#endif
            }

            return(default);
Exemplo n.º 2
0
        private static Hash128 ProduceArtifact(GUID guid, Type importerType, ImportMode mode, out OnDemandState state)
        {
            state = OnDemandState.Unavailable;
            switch (mode)
            {
                #if UNITY_2020_2_OR_NEWER
            case ImportMode.Asynchronous:
                return(AssetDatabaseExperimental.ProduceArtifactAsync(new ArtifactKey(guid, importerType)).value);

            case ImportMode.Synchronous:
                return(AssetDatabaseExperimental.ProduceArtifact(new ArtifactKey(guid, importerType)).value);

            case ImportMode.NoImport:
                var akey = new ArtifactKey(guid, importerType);
                var id   = AssetDatabaseExperimental.LookupArtifact(akey).value;
                if (!id.isValid)
                {
                    state = AssetDatabaseExperimental.GetOnDemandArtifactProgress(akey).state;
                }
                return(id);
                #else
            case ImportMode.Asynchronous:
                return(AssetDatabaseExperimental.GetArtifactHash(guid.ToString(), importerType, AssetDatabaseExperimental.ImportSyncMode.Queue));

            case ImportMode.Synchronous:
                return(AssetDatabaseExperimental.GetArtifactHash(guid.ToString(), importerType));

            case ImportMode.NoImport:
                return(AssetDatabaseExperimental.GetArtifactHash(guid.ToString(), importerType, AssetDatabaseExperimental.ImportSyncMode.Poll));
                #endif
            }

            return(default);