Aline RedrawScopes

Hi there,

Thanks for ALINE, it’s great.

I am trying to use RedrawScopes but I am not able to work out the syntax.

I have some data that is only calculated on some frames. I want to remember what was drawn so that I can draw it on all of the frames until its recalculation time.

Here is one of the attempts I made:

public class Ovrewire : MonoBehaviour
{
    private RedrawScope _redrawScope;
    private bool _firstTime = true;

    void Update()
    {
        if (_firstTime)
        {
            _redrawScope = new RedrawScope();
            var builder = DrawingManager.GetBuilder(renderInGame: true, redrawScope: _redrawScope);
            builder.Line(new float3(0, 80, 400), new float3(100, 130, 400), Color.magenta);
            builder.Dispose();
            _firstTime = false;
        }
        else
        {
            _redrawScope.Draw();
        }
    }
}

It doesnt draw the line except for the first frame.

Hi

The RedrawScope must be created using the DrawingManager.GetRedrawScope method. Since it’s a struct I can unfortunately not prevent anyone from using the constructor without any parameters.

I have clarified the documentation and added a full code example that works. This will be included in the next update.

Here is a working example:

private RedrawScope redrawScope;

void Start() {
    redrawScope = DrawingManager.GetRedrawScope();
    using (var builder = DrawingManager.GetBuilder(redrawScope)) {
        builder.WireSphere(Vector3.zero, 1.0f, Color.red);
    }
}

void Update () {
    redrawScope.Draw();
}

Thank you - that solution worked well