public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <ScrollRect> scrollRect = chunk.GetNativeArray(ScrollRectType); NativeArray <Entity> scrollEntity = chunk.GetNativeArray(EntityType); var rebuildContext = new HierarchyRebuildContext() { ChildrenFromEntity = ChildrenFromEntity, WorldSpaceRectFromEntity = WorldSpaceRectFromEntity, RectTransformFromEntity = RectTransformFromEntity, RebuildFlagFromEntity = RebuildFlagFromEntity, ElementScaleFromEntity = ElementScaleFromEntity, WorldSpaceMaskFromEntity = WorldSpaceMaskFromEntity, RectMaskFromEntity = RectMaskFromEntity }; for (int i = 0; i < scrollRect.Length; i++) { ScrollRect scrollView = scrollRect[i]; ScrollViewTransforms transforms = GatherTransforms(scrollEntity[i], scrollView); var oldContentRect = transforms.ContentRect; transforms.ViewportTransform.AnchorMin = new float2(0.0f, 0.0f); transforms.ViewportTransform.AnchorMax = new float2(1.0f, 1.0f); transforms.ViewportTransform.SizeDelta = new float2(-transforms.VerticalAreaTransform.SizeDelta.x - scrollView.VerticalBarSpacing, -transforms.HorizontalAreaTransform.SizeDelta.y - scrollView.HorizontalBarSpacing); transforms.ViewportRect = RectTransformUtils.CalculateWorldSpaceRect(transforms.ScrollViewRect, ElementScaleFromEntity[scrollEntity[i]].Value, transforms.ViewportTransform); RectTransformFromEntity[scrollView.Viewport] = transforms.ViewportTransform; var contentToViewportRatio = transforms.ViewportRect.Size / transforms.ContentRect.Size; var verticalEntity = scrollView.VerticalBar; if (ScrollBarFromEntity.Exists(verticalEntity)) { UpdateScrollBar(scrollView, verticalEntity, contentToViewportRatio, ref transforms, ScrollBarAxis.Vertical); } var horizontalEntity = scrollView.HorizontalBar; if (ScrollBarFromEntity.Exists(horizontalEntity)) { UpdateScrollBar(scrollView, horizontalEntity, contentToViewportRatio, ref transforms, ScrollBarAxis.Horizontal); } if (NeedUpdate(oldContentRect, transforms.ContentRect)) { var newContentTransform = RectTransformUtils.CalculateInverseTransformWithAnchors(transforms.ContentRect, transforms.ViewportRect, transforms.ContentTransform, ElementScaleFromEntity[scrollView.Content].Value); RectTransformFromEntity[scrollView.Content] = newContentTransform; UpdateScrollRectTransform(scrollEntity[i], transforms.ScrollViewRect, rebuildContext); } } }
protected override JobHandle OnUpdateTransform(JobHandle inputDeps, HierarchyRebuildContext rebuildContext) { UpdateSliderTransform updateJob = new UpdateSliderTransform() { EntityType = GetArchetypeChunkEntityType(), RebuildContext = rebuildContext, ParentFromEntity = GetComponentDataFromEntity <Parent>(true), SliderType = GetArchetypeChunkComponentType <Slider>() }; inputDeps = updateJob.Schedule(m_SliderQuery, inputDeps); return(inputDeps); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { return(OnUpdateTransform(inputDeps, HierarchyRebuildContext.Create(this))); }
protected abstract JobHandle OnUpdateTransform(JobHandle inputDeps, HierarchyRebuildContext rebuildContext);
private void UpdateScrollRectTransform(Entity scrollEntity, WorldSpaceRect scrollRectWorldSpace, HierarchyRebuildContext rebuildContext) { var children = ChildrenFromEntity[scrollEntity]; var scrollMask = WorldSpaceMaskFromEntity[scrollEntity]; var scale = ElementScaleFromEntity[scrollEntity].Value; for (int j = 0; j < children.Length; j++) { RectTransformUtils.UpdateTransformRecursive(ref scrollRectWorldSpace, scrollMask, children[j].Value, scale, ref rebuildContext); } }