Exemplo n.º 1
0
        private void IndexObjects(GameObject[] objects, string type, string containerName, string containerPath, bool checkIfDocumentExists)
        {
            var options   = settings.options;
            var globalIds = new GlobalObjectId[objects.Length];

            GlobalObjectId.GetGlobalObjectIdsSlow(objects, globalIds);

            for (int i = 0; i < objects.Length; ++i)
            {
                var obj = objects[i];
                if (!obj || (obj.hideFlags & (HideFlags.DontSave | HideFlags.HideInHierarchy)) != 0)
                {
                    continue;
                }

                var gid = globalIds[i];
                if (gid.identifierType == 0 || gid.assetGUID.Empty())
                {
                    continue;
                }

                if (PrefabUtility.IsPrefabAssetMissing(obj))
                {
                    continue;
                }

                if (obj.tag?.Equals("noindex~", StringComparison.Ordinal) ?? false)
                {
                    continue;
                }

                var id            = gid.ToString();
                var transformPath = SearchUtils.GetTransformPath(obj.transform);
                var documentIndex = AddDocument(id, options.types ? transformPath : null, containerPath, checkIfDocumentExists, SearchDocumentFlags.Nested | SearchDocumentFlags.Object);

                if (options.types)
                {
                    IndexNumber(documentIndex, "depth", GetObjectDepth(obj));
                    IndexProperty(documentIndex, "from", type, saveKeyword: true, exact: true);
                }

                if (options.dependencies)
                {
                    IndexProperty(documentIndex, type, containerName, saveKeyword: false);
                    IndexProperty(documentIndex, type, containerPath, exact: true, saveKeyword: false);
                }

                IndexWord(documentIndex, Path.GetFileName(transformPath));
                IndexProperty(documentIndex, "is", "nested", saveKeyword: true, exact: true);
                IndexGameObject(documentIndex, obj, options);
                IndexCustomGameObjectProperties(id, documentIndex, obj);
            }
        }
Exemplo n.º 2
0
        private static object GetObjectPath(SearchColumnEventArgs args)
        {
            var value = args.column.SelectValue(args.item, args.context);

            if (value is UnityEngine.Object obj)
            {
                var objPath = AssetDatabase.GetAssetPath(obj);
                if (!string.IsNullOrEmpty(objPath))
                {
                    return(objPath);
                }
                if (obj is GameObject go)
                {
                    return(SearchUtils.GetTransformPath(go.transform));
                }
            }
            return(value);
        }