public void RestoreHierarchy(AssetDocumentHierarchyElementContainer hierarchyElementContainer, IPsiSourceFile sourceFile) { if (myIsRestored) { return; } lock (myLockObject) { if (myIsRestored) { return; } myIsRestored = true; AssetDocumentHierarchyElementContainer = hierarchyElementContainer; IsScene = sourceFile.GetLocation().ExtensionWithDot.Equals(UnityYamlConstants.Scene); var offset = 0; // concating arrays to one by index. see GetElementByInternalIndex too PrepareElements(myOtherBoxedElements, offset); offset += myOtherBoxedElements.Count; PrepareElements(myTransformElements, offset); offset += myTransformElements.Count; PrepareElements(myGameObjectHierarchies, offset); offset += myGameObjectHierarchies.Count; PrepareElements(myComponentElements, offset); offset += myComponentElements.Count; PrepareElements(myScriptComponentElements, offset); offset += myScriptComponentElements.Count; foreach (var prefabInstanceHierarchy in GetPrefabInstanceHierarchies()) { var correspondingSourceObjects = new HashSet <ExternalReference>(); foreach (var modification in prefabInstanceHierarchy.PrefabModifications) { var target = modification.Target; if (!(target is ExternalReference externalReference)) { continue; } correspondingSourceObjects.Add(externalReference); } foreach (var correspondingSourceObject in correspondingSourceObjects) { var fakeAnchor = PrefabsUtil.GetImportedDocumentAnchor(prefabInstanceHierarchy.Location.LocalDocumentAnchor, correspondingSourceObject.LocalDocumentAnchor); myOtherFakeStrippedElements.Add(new StrippedHierarchyElement( new LocalReference(sourceFile.PsiStorage.PersistentIndex, fakeAnchor), prefabInstanceHierarchy.Location, correspondingSourceObject)); } } } }
public AssetHierarchyProcessor(IShellLocks locks, PrefabImportCache prefabImportCache, AssetDocumentHierarchyElementContainer assetDocumentHierarchyElementContainer) { myLocks = locks; myPrefabImportCache = prefabImportCache; myAssetDocumentHierarchyElementContainer = assetDocumentHierarchyElementContainer; }