Example #1
0
        internal ObjectIndexer(string rootName, SearchDatabase.Settings settings)
            : base(rootName)
        {
            this.name     = settings?.name ?? name;
            this.settings = settings;

            m_QueryEngine.SetSearchDataCallback(e => null);
            LoadCustomObjectIndexers();
        }
Example #2
0
 internal ObjectIndexer(string name, SearchDatabase.Settings settings)
     : base(name)
 {
     this.settings = settings;
     m_QueryEngine.SetSearchDataCallback(e => null, s =>
     {
         if (s.Length < k_MinWordIndexationLength)
         {
             return(null);
         }
         return(s);
     }, StringComparison.Ordinal);
     LoadCustomObjectIndexers();
 }
Example #3
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            var settings = new SearchDatabase.Settings
            {
                guid      = null,
                root      = null,
                roots     = null,
                source    = null,
                name      = null,
                baseScore = 0,
                excludes  = null,
                includes  = null,

                type    = type,
                options = GetOptions(),
            };

            EditorApplication.LockReloadAssemblies();
            try
            {
                var indexer = SearchDatabase.CreateIndexer(settings);
                indexer.IndexDocument(ctx.assetPath, false);
                indexer.ApplyUnsorted();

                var indexArtifactPath = ctx.GetResultPath($"{type}.{(int)options:X}.index".ToLowerInvariant());
                using (var fileStream = new FileStream(indexArtifactPath, FileMode.CreateNew, FileAccess.Write, FileShare.Read))
                    indexer.Write(fileStream);

                Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"\nGenerated {type} ({GetType().Name}) {indexArtifactPath} for {ctx.assetPath} with {options}");

                ctx.DependsOnSourceAsset(Path.GetDirectoryName(ctx.assetPath).Replace("\\", "/"));
                ctx.DependsOnCustomDependency(GetType().GUID.ToString("N"));

                #if UNITY_2020_1_OR_NEWER
                ctx.DependsOnCustomDependency(nameof(CustomObjectIndexerAttribute));
                #endif
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                ctx.LogImportError(ex.Message);
            }
            finally
            {
                EditorApplication.UnlockReloadAssemblies();
            }
        }
Example #4
0
 public SceneIndexer(SearchDatabase.Settings settings)
     : base(String.IsNullOrEmpty(settings.name) ? "objects" : settings.name, settings)
 {
 }
Example #5
0
 public AssetIndexer(SearchDatabase.Settings settings)
     : base("assets", settings)
 {
     getEntryComponentsHandler = GetEntryComponents;
 }
 internal ObjectIndexer(string name, SearchDatabase.Settings settings)
     : base(name)
 {
     this.settings = settings;
 }
Example #7
0
 public AssetIndexer(SearchDatabase.Settings settings)
     : base(String.IsNullOrEmpty(settings.name) ? "assets" : settings.name, settings)
 {
 }
 public SceneIndexer(SearchDatabase.Settings settings)
     : base("objects", settings)
 {
     getEntryComponentsHandler = GetEntryComponents;
 }