Fully scripted GUI, TextureButton

1000h1000h Posts: 133Member
edited August 2016 in Tutorials
CRITICAL STEP IN ORDER FOR CUSTOM GUI ELEMENTS TO DISPLAY:

In order to make custom GUI CANVAS ELEMENT DERIVED CALSS in GODOT SCRIPT and not through the visual editor,
the critical step to do is .add_child() the CANVAS ITEM to a CONTROL PARENT

EXAMPLE:

#The function button() is written within the script of a control

func button(): var button = Button.new() button.set_text('hello') return button

#Then, in the _draw() function of the control, 

func _draw():
self.add_child(label())

Comments

  • 1000h1000h Posts: 133Member
    edited August 2016 Answer ✓
    var image = ImageTexture.new()
    image.load("res://HudTextures/Icons/Icon.png")

    var texture = draw_texture_rect(image,Rect2(Vector2(255,255),Vector2(255,255)),0,Color(1,1,1,1))
Sign In or Register to comment.