protected override void ConvertComponent(Canvas unityComponent, Entity entity, RectTransformToEntity rectTransformToEntity, Dictionary <UnityEngine.Object, Entity> assetToEntity, EntityManager commandBuffer) { CanvasSortLayer image = new CanvasSortLayer { Value = unityComponent.sortingOrder }; commandBuffer.AddComponentData(entity, image); commandBuffer.AddComponent(entity, typeof(RebuildCanvasHierarchyFlag)); commandBuffer.AddBuffer <MeshVertex>(entity); commandBuffer.AddBuffer <MeshVertexIndex>(entity); commandBuffer.AddBuffer <SubMeshInfo>(entity); if (unityComponent.renderMode != RenderMode.ScreenSpaceCamera) { throw new InvalidOperationException($"Canvas ({unityComponent}) render mode ({unityComponent.renderMode}) is not supported yet"); } if (unityComponent.worldCamera == null) { throw new InvalidOperationException($"Target camera is null or destroyed. Canvas {unityComponent}"); } var proxy = unityComponent.worldCamera.GetComponent <CameraImageRenderProxy>(); if (proxy == null) { proxy = unityComponent.worldCamera.gameObject.AddComponent <CameraImageRenderProxy>(); } commandBuffer.AddSharedComponentData(entity, new CanvasTargetCamera() { Target = proxy }); }
private void ConvertCanvas(Canvas canvas) { var entity = GetPrimaryEntity(canvas); CanvasSortLayer image = new CanvasSortLayer { Value = canvas.sortingOrder }; DstEntityManager.AddComponentData(entity, image); DstEntityManager.AddComponent(entity, typeof(RebuildCanvasHierarchyFlag)); DstEntityManager.AddBuffer <MeshVertex>(entity); DstEntityManager.AddBuffer <MeshVertexIndex>(entity); DstEntityManager.AddBuffer <SubMeshInfo>(entity); if (canvas.renderMode == RenderMode.WorldSpace) { throw new InvalidOperationException($"Canvas ({canvas}) render mode ({canvas.renderMode}) is not supported yet"); } if (canvas.renderMode == RenderMode.ScreenSpaceCamera) { SetUpScreenSpaceCamera(canvas, entity); } else if (canvas.renderMode == RenderMode.ScreenSpaceOverlay) { SetUpScreenSpaceOverlay(canvas, entity); } }
private void ConvertCanvas(Canvas canvas) { var entity = GetPrimaryEntity(canvas); CanvasSortLayer image = new CanvasSortLayer { Value = canvas.sortingOrder }; DstEntityManager.AddComponentData(entity, image); DstEntityManager.AddComponent(entity, typeof(RebuildCanvasHierarchyFlag)); DstEntityManager.AddBuffer <MeshVertex>(entity); DstEntityManager.AddBuffer <MeshVertexIndex>(entity); DstEntityManager.AddBuffer <SubMeshInfo>(entity); if (canvas.renderMode != RenderMode.ScreenSpaceCamera) { throw new InvalidOperationException($"Canvas ({canvas}) render mode ({canvas.renderMode}) is not supported yet"); } if (canvas.worldCamera == null) { throw new InvalidOperationException($"Target camera is null or destroyed. Canvas {canvas}"); } var proxy = canvas.worldCamera.GetComponent <CameraImageRenderProxy>(); if (proxy == null) { proxy = canvas.worldCamera.gameObject.AddComponent <CameraImageRenderProxy>(); } DstEntityManager.AddSharedComponentData(entity, new CanvasTargetCamera() { Target = proxy }); }