How To Wait Until EditableImage Fully Loads?

I’m trying to make a glitch effect where randomly colored squares tile the screen and rapidly change colors.

For that I started using EditableImages and set up this demo:

local AssetService = game:GetService('AssetService')
local Camera = workspace.CurrentCamera

function Render(FullSize: Vector2)
    local Size = FullSize / 10
    Size = Vector2.new(math.ceil(Size.X), math.ceil(Size.Y))
    local Length = Size.X * Size.Y * 4
    local ImageBuffer = buffer.create(Length)
    for i = 1, Length do 
        buffer.writeu8(ImageBuffer, i - 1,
            i % 4 == 0 and 255 or math.random(0, 255))
    end
    local EditableImage = AssetService:CreateEditableImage({Size = Size})
    EditableImage:WritePixelsBuffer(Vector2.zero, Size, ImageBuffer)
    script.Parent.ImageContent = Content.fromObject(EditableImage)
end

Render(Camera.ViewportSize)

My issue is that there’s a flicker every time I set the ImageContent of the ImageLabel.
I want the solution to be properly timed delays and associated pre-rendering bc that sounds like the most robust, and to properly time it I need like an event for when the image has appeared on the ImageLabel or at the very least the ability to check if it’s finished conditionally.

So, do I have any access to know when the image rendered or to know when to wait for the image to render?

1 Like

You could attempt to have multiple images, layered on top of each other, and slowly remove the top one, working backwards. I’m not sure if ContentProvider applies to this kind of content, but might be worth a look.

1 Like

Yeah that layering sounds great, and theoretically I should only need 2 layers as long as I can accurately predict when each loads.
Fortunately ContentProvider has 3 distinct methods of figuring if assets are loading.
Unfortunately all 3 are exclusive to DOWNloading, which as of right now EditableImage doesn’t even do (replication is broken) and even if creating it on the server and waiting for replication would give me access to the load yeild times, those times would also probably skyrocket which is undesirable.

I think I will just create and load every frame asap and then display them at a constant rate after the fact.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.