public override void OnImportAsset(AssetImportContext ctx) { var settings = new SearchDatabase.Settings { type = "asset", options = GetOptions() }; var indexer = SearchDatabase.CreateIndexer(settings); try { indexer.IndexDocument(ctx.assetPath, false); indexer.Finish(removedDocuments: null); var indexArtifactPath = ctx.GetOutputArtifactFilePath($"{(int)options:X}.index".ToLowerInvariant()); using (var fileStream = new FileStream(indexArtifactPath, FileMode.CreateNew, FileAccess.Write, FileShare.None)) indexer.Write(fileStream); ctx.DependsOnSourceAsset(ctx.assetPath); ctx.DependsOnCustomDependency(GetType().GUID.ToString("N")); ctx.DependsOnCustomDependency(nameof(CustomObjectIndexerAttribute)); } catch (Exception ex) { ctx.LogImportError($"Failed to build search index for {ctx.assetPath}\n{ex}"); } }
public override void OnImportAsset(AssetImportContext ctx) { var settings = new SearchDatabase.Settings { type = "asset", options = GetOptions() }; try { var indexer = SearchDatabase.CreateIndexer(settings); try { ctx.DependsOnCustomDependency(GetType().GUID.ToString("N")); ctx.DependsOnCustomDependency(nameof(CustomObjectIndexerAttribute)); indexer.IndexDocument(ctx.assetPath, false); indexer.ApplyUnsorted(); } catch (Exception ex) { ctx.LogImportError($"Failed to build search index for {ctx.assetPath}\n{ex}"); } #if USE_SEARCH_MODULE var indexArtifactPath = ctx.GetOutputArtifactFilePath($"{(int)options:X}.index".ToLowerInvariant()); #else var indexArtifactPath = ctx.GetResultPath($"{(int)options:X}.index".ToLowerInvariant()); #endif using (var fileStream = new FileStream(indexArtifactPath, FileMode.CreateNew, FileAccess.Write, FileShare.Read)) indexer.Write(fileStream); } catch (Exception ex) { ctx.LogImportError(ex.Message); } }
public AssetIndexer(SearchDatabase.Settings settings) : base(string.IsNullOrEmpty(settings.name) ? "assets" : settings.name, settings) { }
internal ObjectIndexer(string name, SearchDatabase.Settings settings) : base(name) { this.settings = settings; }