How to dynamically change GUI Image

In script, C# specifically, is it possible to change the image of a GUI Image control. If so how? I’ve tried to change the IBrush of the control but it seems like textures and materials can’t be cast to an IBrush. What would i need to change if it’s possible?

I’ve also tried looking at the docs, there’s some help but i didn’t see anything about creating / modifying UI controls that use images.

Thank you.

IBrush is just interface for different brush types. For example, TextureBrush draws brush with a texture.

Example:

public class MyScript : Script
{
    public UIControl Image;
    public Texture Tex;

    public override void OnStart()
    {
        Image.Get<Image>().Brush = new TextureBrush(Tex);
    }
}

I see! I Should have thought about that, I was wondering what implemented it at first.
It works.

Turns out i was looking in the wrong place sorry, there is a section about the different types of brushes.

Thank you!