private void ProcessHierarchy(AssetDocumentHierarchyElement owner, IHierarchyElement element, IGameObjectConsumer consumer, bool prefabImport, HashSet <ulong> visited) { if (element == null) { return; } if (visited.Contains(element.Location.LocalDocumentAnchor)) { return; } if (element is IGameObjectHierarchy gameObjectHierarchy) { ProcessGameObject(owner, gameObjectHierarchy, consumer, prefabImport, visited); } else if (element is IComponentHierarchy componentHierarchy) { var gameObjectReference = componentHierarchy.OwningGameObject; var gameObject = myAssetDocumentHierarchyElementContainer.GetHierarchyElement(gameObjectReference, prefabImport) as IGameObjectHierarchy; ProcessGameObject(owner, gameObject, consumer, prefabImport, visited); } else { Assertion.Fail($"Unsupported type: {element.GetType().Name}"); } }
private void ProcessGameObject(AssetDocumentHierarchyElement owner, IGameObjectHierarchy gameObject, IGameObjectConsumer consumer, bool prefabImport, HashSet <ulong> visited) { var transform = gameObject?.GetTransformHierarchy(owner); if (transform == null) { return; } if (!consumer.AddGameObject(owner, gameObject)) { return; } var parentTransform = myAssetDocumentHierarchyElementContainer.GetHierarchyElement(transform.ParentTransform, prefabImport) as ITransformHierarchy; if (parentTransform == null) { return; } visited.Add(gameObject.Location.LocalDocumentAnchor); ProcessHierarchy(owner, parentTransform, consumer, prefabImport, visited); }
public void ProcessSceneHierarchyFromComponentToRoot(LocalReference location, IGameObjectConsumer consumer, bool forcePrefabImportForStartPoint, bool forcePrefabImport) { myLocks.AssertReadAccessAllowed(); var owner = myAssetDocumentHierarchyElementContainer.GetAssetHierarchyFor(location, out var guid); if (owner == null) { return; } if (guid == null) { return; } var hierarchyElement = owner.GetHierarchyElement(guid.Value, location.LocalDocumentAnchor, forcePrefabImportForStartPoint ? myPrefabImportCache : null); if (hierarchyElement is IStrippedHierarchyElement && !forcePrefabImportForStartPoint) { return; } ProcessSceneHierarchyFromComponentToRoot(hierarchyElement, consumer, forcePrefabImport); }
public void ProcessSceneHierarchyFromComponentToRoot(IHierarchyElement hierarchyElement, IGameObjectConsumer consumer, bool forcePrefabImport) { myLocks.AssertReadAccessAllowed(); if (hierarchyElement == null) { return; } Assertion.Assert(!(hierarchyElement is IStrippedHierarchyElement), "!hierarchyElement.IsStripped"); // stripped elements should be never returned, Assertion.Assert(!(hierarchyElement is IPrefabInstanceHierarchy), "Process should not be started from prefab instance, use corresponding GO"); var owner = myAssetDocumentHierarchyElementContainer.GetAssetHierarchyFor(hierarchyElement.Location, out _); if (owner == null) { return; } ProcessHierarchy(owner, hierarchyElement, consumer, forcePrefabImport, new HashSet <ulong>()); }