UI Toolbox logoUI Toolbox

ElementImage

ElementImage in UIToolbox saves what an element shows, such as a Graph or a PieChart, as an image. It reads the rendered frame at the end of the frame: the screen, or the targetTexture of the panel settings.

ElementImage.SavePng(graph, Path.Combine(Application.persistentDataPath, "graph.png"), ok => Debug.Log(ok ? "saved" : "failed"));
ElementImage.Capture(pie, texture => { /* use the texture, then Destroy it */ });
Member Description
Capture(element, done) Copies the pixels of the element into a new RGBA32 texture, the right way up. The caller owns the texture. done gets null outside Play mode, off a runtime panel, or when the element does not show.
Capture(panel, worldRect, done) The same for a rectangle of a panel, in world units. The ColorPicker eyedropper reads one pixel with it.
SavePng(element, path, done) Captures the element and writes a PNG file. done gets false when there is no image or the file cannot be written (the error is logged).