예제 #1
0
        internal static object GetPrefabRoot(SearchItem item)
        {
            var prefab = item.ToObject();

            if (!prefab)
            {
                return(null);
            }
            var rootPrefab = PrefabUtility.GetOriginalSourceOrVariantRoot(prefab);

            if (rootPrefab == null || prefab == rootPrefab)
            {
                return(null);
            }
            return(rootPrefab);
        }
예제 #2
0
        internal static void IndexPrefabProperties(int documentIndex, GameObject prefab, ObjectIndexer indexer)
        {
            var prefabType = PrefabUtility.GetPrefabAssetType(prefab);

            indexer.IndexProperty(documentIndex, "prefab", prefabType.ToString(), saveKeyword: true, exact: true);

            if (prefabType != PrefabAssetType.NotAPrefab)
            {
                indexer.IndexProperty(documentIndex, "prefab", "any", saveKeyword: true, exact: true);
            }

            var rootPrefab = PrefabUtility.GetOriginalSourceOrVariantRoot(prefab);

            if (rootPrefab != null && rootPrefab != prefab)
            {
                indexer.AddReference(documentIndex, "root", rootPrefab, "Root Prefab", typeof(GameObject));
            }

            var source = PrefabUtility.GetCorrespondingObjectFromSource(prefab);

            if (source != null && source != prefab)
            {
                indexer.AddReference(documentIndex, "base", source, "Base Prefab", typeof(GameObject));
            }

            if (rootPrefab == null || source == null)
            {
                indexer.IndexProperty(documentIndex, "prefab", "base", saveKeyword: true, exact: true);
            }

            if (PrefabUtility.HasPrefabInstanceAnyOverrides(prefab, false))
            {
                indexer.IndexProperty(documentIndex, "prefab", "modified", saveKeyword: true, exact: true);
            }

            if (PrefabUtility.HasPrefabInstanceAnyOverrides(prefab, true))
            {
                indexer.IndexProperty(documentIndex, "prefab", "altered", saveKeyword: true, exact: true);
            }
        }