Can someone spell out to us how to do a color rect programmatically in c# and display it.

I can't figure out the documentation and seeing something to work backwards from to use the methods and inheritance classes would be very useful.

Along the lines of:
Colorrect r1 = new ColorRect(x y color);

That's what I'm looking for.

Thanks

I don't know if this helps, but in GDScript you could do it like this:

var c: ColorRect = ColorRect.new()
c.rect_position = Vector2(1.0, 2.0)
c.rect_size = Vector2(3.0, 4.0)
c.color = Color(1, 0, 0, 1)

To display it, add it to the scene tree, typically using add_child() (or the C# equivalent).

    DaveTheCoder

    I've had a mess around this morning and got it!

        ColorRect my1 = new ColorRect();
        
        my1.RectPosition = new Vector2(100,150);
        my1.RectSize = new Vector2(100,200);
        my1.Color = new Color(1,0,0,1);
        AddChild(my1);

    C# Resources on godot confuse me as I'm trying to figure out how to 'logically' work backwards from the end node ie ColorRect to find properties in the inheritance chain.

    
    // Node type, node name = create a new one and call the method ()
    ColorRect my1 = new ColorRect();
        
       // access the object. object property = create the vector2 (x coord,y coord)
        my1.RectPosition = new Vector2(100,150);
       // create a vector2 for sixe (x, y)
        my1.RectSize = new Vector2(100,200);
    // access the colour(British lol) = create the color Color(reg, green, blue, alpha(transparancy))
        my1.Color = new Color(1,0,0,1);
    // add the new object to the scene
        AddChild(my1);

    Edit: Added code comments for future reference

    C# Resources on godot confuse me as I'm trying to figure out how to 'logically' work backwards from the end node ie ColorRect to find properties in the inheritance chain.