Exemple #1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var entityType = GetArchetypeChunkEntityType();
            var childType  = GetArchetypeChunkBufferType <Child>(true);

            var dpi = ScreenUtils.GetScaledDpi();
            var updateHierarchyJob = new UpdateHierarchy
            {
                Dpi = new float2(dpi, dpi),
                RectTransformType      = GetArchetypeChunkComponentType <RectTransform>(true),
                CanvasSizeType         = GetArchetypeChunkComponentType <CanvasScreenSize>(true),
                EntityType             = entityType,
                ChildType              = childType,
                ConstantPhysicalScaler = GetArchetypeChunkComponentType <CanvasConstantPhysicalSizeScaler>(true),
                ConstantPixelScaler    = GetArchetypeChunkComponentType <CanvasConstantPixelSizeScaler>(true),
                RebuildContext         = HierarchyRebuildContext.Create(this)
            };
            var updateHierarchyJobHandle = updateHierarchyJob.Schedule(m_Group, inputDeps);

            return(updateHierarchyJobHandle);
        }
Exemple #2
0
 private static void UpdateRectMask(Entity entity, WorldSpaceRect elementRect, ref WorldSpaceMask mask, ref HierarchyRebuildContext rebuildContext)
 {
     if (rebuildContext.RectMaskFromEntity.Exists(entity))
     {
         float2 newMin = math.max(mask.Min, elementRect.Min);
         float2 newMax = math.min(mask.Max, elementRect.Max);
         mask = new WorldSpaceMask
         {
             Min = newMin,
             Max = newMax
         };
     }
 }
Exemple #3
0
        public static void UpdateTransformRecursive(ref WorldSpaceRect parentLocalToWorldSpaceRect, WorldSpaceMask currentMask, Entity entity, float2 scale, ref HierarchyRebuildContext rebuildContext)
        {
            var childTransform    = rebuildContext.RectTransformFromEntity[entity];
            var childLocalToWorld = CalculateWorldSpaceRect(parentLocalToWorldSpaceRect, scale, childTransform);

            rebuildContext.WorldSpaceRectFromEntity[entity] = childLocalToWorld;
            rebuildContext.ElementScaleFromEntity[entity]   = new ElementScale()
            {
                Value = scale
            };
            UpdateRectMask(entity, childLocalToWorld, ref currentMask, ref rebuildContext);
            rebuildContext.WorldSpaceMaskFromEntity[entity] = currentMask;

            if (rebuildContext.RebuildFlagFromEntity.Exists(entity))
            {
                rebuildContext.RebuildFlagFromEntity[entity] = new RebuildElementMeshFlag()
                {
                    Rebuild = true
                }
            }
            ;
            if (rebuildContext.ChildrenFromEntity.Exists(entity))
            {
                var children = rebuildContext.ChildrenFromEntity[entity];
                for (int i = 0; i < children.Length; i++)
                {
                    UpdateTransformRecursive(ref childLocalToWorld, currentMask, children[i].Value, scale, ref rebuildContext);
                }
            }
        }