public static void ConvertRectTransformsRecursive(UnityEngine.RectTransform parent, Entity parentEntity, RectTransformToEntity rectTransformToEntity, EntityManager commandBuffer, ref DotsUIArchetypes archetypes, ref NativeList <LinkedEntityGroup> linkedGroup, bool isPrefab) { rectTransformToEntity.Add(parent, parentEntity); linkedGroup.Add(parentEntity); #if UNITY_EDITOR commandBuffer.SetName(parentEntity, parent.name); #endif m_PooledRectTransformList.Add(parent); int childCount = parent.childCount; for (int i = 0; i < childCount; i++) { if (parent.GetChild(i) is UnityEngine.RectTransform childTransform) { //if(!childTransform.gameObject.activeInHierarchy) // continue; Entity child = commandBuffer.CreateEntity(archetypes.GenericChildArchetype); SetRectTransform(commandBuffer, childTransform, child); commandBuffer.SetComponentData(child, new Parent() { Value = parentEntity }); if (isPrefab) { commandBuffer.AddComponent(child, typeof(Prefab)); } ConvertRectTransformsRecursive(childTransform, child, rectTransformToEntity, commandBuffer, ref archetypes, ref linkedGroup, isPrefab); } } }
public static void ConvertCanvasHierarchy(Canvas root, EntityManager manager, RectTransformToEntity rectTransformToEntity) { Initialize(); var archetypes = new DotsUIArchetypes(manager); var assetToEntity = new Dictionary <UnityEngine.Object, Entity>(); var entity = manager.CreateEntity(archetypes.CanvasArchetype); var linkedGroup = new NativeList <LinkedEntityGroup>(Allocator.Temp);//manager.AddBuffer<LinkedEntityGroup>(entity); linkedGroup.Add(entity); ConvertRectTransformsRecursive(root.GetComponent <UnityEngine.RectTransform>(), entity, rectTransformToEntity, manager, ref archetypes, ref linkedGroup, false); manager.AddBuffer <LinkedEntityGroup>(entity).AddRange(linkedGroup.AsArray()); UpdateComponents(rectTransformToEntity, assetToEntity, manager); }
internal static Entity ConvertPrefabHierarchy(UnityEngine.RectTransform root, EntityManager manager, RectTransformToEntity rectTransformToEntity) { Initialize(); var archetypes = new DotsUIArchetypes(manager); var assetToEntity = new Dictionary <UnityEngine.Object, Entity>(); var entity = manager.CreateEntity(archetypes.GenericChildArchetype); SetRectTransform(manager, root, entity); var linkedGroup = new NativeList <LinkedEntityGroup>(Allocator.Temp); ConvertRectTransformsRecursive(root.GetComponent <UnityEngine.RectTransform>(), entity, rectTransformToEntity, manager, ref archetypes, ref linkedGroup, true); manager.AddBuffer <LinkedEntityGroup>(entity).AddRange(linkedGroup.AsArray()); UpdateComponents(rectTransformToEntity, assetToEntity, manager); return(entity); }