ALine ECS editor System flickering

  • ALINE version: [1.7.9]
  • Unity version: [6000.5.9f1]
  • Render pipeline: [URP 17.50]

I found when writing an editor world ECS system, that ALine flickers while in editor mode.

In scene view, it flickers constantly.
In game view, it wont show while the mouse moves in the viewport, however when the mouse moves outside of it, it does update.

I believe this has to do with how the ECS editor updates. it seems to update at different intervals. A lower fps in scene view, and it only updates for game view when the mouse moves over other panels.

Is there a fix or work around for this limitation?

Hi

Could you share the code you are using?

As a work around, do you have the option of rendering ALINE outside of ECS and passing the data to it?

Yes sorry my bad, I had realized yesterday I forgot and had to intended to update, and forgot again.

using DBD_ECS.Runtime.Components.Splines;
using Drawing;
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;

namespace DBD_ECS.Runtime.Systems.Drawing
{
    [WorldSystemFilter(WorldSystemFilterFlags.Default | WorldSystemFilterFlags.Editor)]
    [UpdateInGroup(typeof(PresentationSystemGroup), OrderLast = true)]
    [BurstCompile]
    public partial struct SplineSegmentDrawSystem : ISystem
    {
        EntityQuery labelQuery;
        
        [BurstCompile]
        public void OnCreate(ref SystemState state)
        {
            labelQuery = SystemAPI.QueryBuilder()
                .WithAll<LocalToWorld, SplineSetting, SplineColor, SegmentPointCached>()
                .Build();
        }

        

        public void OnUpdate(ref SystemState state)
        {
            var builder = DrawingManager.GetBuilder( false);
            var handle = new SegmentDrawingJob
            {
                builder = builder
            }.ScheduleParallel(labelQuery, state.Dependency);
            builder.DisposeAfter(handle);
            state.Dependency = handle;
        }
    }

    [BurstCompile]
    internal partial struct SegmentDrawingJob : IJobEntity
    {
        public CommandBuilder builder;

        void Execute([EntityIndexInQuery] int index, in LocalToWorld localToWorld, SplineSetting settings, SplineColor color, DynamicBuffer<SegmentPointCached> cachePositions)
        {
            builder.PushColor((Vector4)color.value);
            builder.PushLineWidth(settings.Thickness);
            builder.PushMatrix(localToWorld.Value);
            builder.Polyline(cachePositions.Reinterpret<float3>().AsNativeArray());
            builder.PopMatrix();
            builder.PopLineWidth();
            builder.PopColor();

        }
    }
}

I could however I’m trying to avoid where I can for a few reasons.

  1. Doing anything outside of ECS systems risks issues with forcing syncs.

  2. It can be tricky getting the correct batch of data at the right time for being displayed.

But I could probably create some monobehaviour that reads the ECS data and draws, I was just trying to keep things in ECS.

Gotcha. Yeah Aron may have a more elegant solution for you than mine here. I’ve never gotten to play around with ECS much so it’s a bit of my blind spot.