コード例 #1
0
        public IHierarchyElement GetHierarchyElement(string ownerGuid, ulong anchor, PrefabImportCache prefabImportCache)
        {
            if (myLocalAnchorToHierarchyElement.TryGetValue(anchor, out var result))
            {
                if (!result.IsStripped || prefabImportCache == null) // stipped means, that element is not real and we should import prefab
                {
                    return(result);
                }
            }

            if (result != null && IsScene && result.IsStripped)
            {
                var prefabInstance      = result.PrefabInstance;
                var correspondingObject = result.CorrespondingSourceObject;
                if (prefabInstance != null && correspondingObject != null)
                {
                    anchor = PrefabsUtil.Import(prefabInstance.LocalDocumentAnchor, correspondingObject.LocalDocumentAnchor);
                }
            }

            if (prefabImportCache != null)
            {
                var elements = prefabImportCache.GetImportedElementsFor(ownerGuid, this);

                if (elements.TryGetValue(anchor, out var importedResult))
                {
                    return(importedResult);
                }
            }

            return(null);
        }
コード例 #2
0
 public AssetDocumentHierarchyElementContainer(IPersistentIndexManager manager, PrefabImportCache prefabImportCache, IShellLocks shellLocks,
                                               UnityExternalFilesModuleFactory psiModuleProvider, MetaFileGuidCache metaFileGuidCache, IEnumerable <IAssetInspectorValueDeserializer> assetInspectorValueDeserializers)
 {
     myManager           = manager;
     myPrefabImportCache = prefabImportCache;
     myShellLocks        = shellLocks;
     myPsiModule         = psiModuleProvider.PsiModule;
     myMetaFileGuidCache = metaFileGuidCache;
     myAssetInspectorValueDeserializers = assetInspectorValueDeserializers;
 }
コード例 #3
0
        public IHierarchyElement GetHierarchyElement(Guid?ownerGuid, ulong anchor, PrefabImportCache prefabImportCache)
        {
            var result = SearchForAnchor(anchor);

            if (result != null)
            {
                if (!(result is IStrippedHierarchyElement) || prefabImportCache == null) // stipped means, that element is not real and we should import prefab
                {
                    return(result);
                }
            }

            // In prefabs files, anchor for stripped element is always generated by formula in PrefabsUtil. This means
            // that after we import elements from prefab file into another file, we could reuse anchor from stripped element to
            // get real element (in current implementation, imported objects are store in PrefabImportCache)
            // It is not true(!!!) for scene files, anchors for scene files could be generated by sequence generator. This means,
            // that anchor for stripped element could be '19' for example, but imported element will have another anchor.
            //
            // To unify all logic, if ownerGuid is related to scene file and achor points to stripped file, we will
            // use new anchor which calculated in same way with prefab import
            if (result != null && IsScene && result is IStrippedHierarchyElement strippedHierarchyElement)
            {
                var prefabInstance      = strippedHierarchyElement.PrefabInstance;
                var correspondingObject = strippedHierarchyElement.CorrespondingSourceObject;
                anchor = PrefabsUtil.GetImportedDocumentAnchor(prefabInstance.LocalDocumentAnchor, correspondingObject.LocalDocumentAnchor);
            }

            if (prefabImportCache != null && ownerGuid != null)
            {
                var elements = prefabImportCache.GetImportedElementsFor(ownerGuid.Value, this);

                if (elements.TryGetValue(anchor, out var importedResult))
                {
                    return(importedResult);
                }
            }

            return(null);
        }
コード例 #4
0
 public AssetHierarchyProcessor(IShellLocks locks, PrefabImportCache prefabImportCache, AssetDocumentHierarchyElementContainer assetDocumentHierarchyElementContainer)
 {
     myLocks             = locks;
     myPrefabImportCache = prefabImportCache;
     myAssetDocumentHierarchyElementContainer = assetDocumentHierarchyElementContainer;
 }