/// <summary>Called just before the image is about to be drawn (only ever when it's actually visible). /// Note that everything else - e.g. ImageMaterial or Width/Height - is always called after this.</summary> public override void OnLayout(Css.RenderableData context, LayoutBox box, out float width, out float height) { // Get the shape of the element: width = box.PaddedWidth; height = box.PaddedHeight; // Tell the context which may trigger a redraw: Context.SetSize((int)width, (int)height); }
/// <summary>Renders this SVG at the given size. /// Get the Texture property on the object returned. /// This also caches nothing - it's a one-shot texture.</summary> public UnityEngine.Texture RenderOnce(int width, int height) { // Create the context and draws the first time: RenderContext rc = new RenderContext(svgElement); // Update the size (Which triggers a draw): rc.SetSize(width, height); // Return the image: return(rc.Texture); }