Can't click on TextureButton

yursan9yursan9 Posts: 6Member
edited December 1969 in GUI
Hey, guys! I want to ask something about my game. When I made some TextureButton in my scene, the first one is working fine. The rest is simply an unclickable buttons.<br /><br />I connected the button by GUI.<br /><br />This is my code:<br />
<br />extends TextureFrame<br /><br />onready var tab = 1<br />	<br />func _process(delta):<br />	if tab == 1:<br />		get_node(&quot;layer/prev&quot;).hide()<br />		get_node(&quot;frame/1&quot;).set_hidden(false)<br />		get_node(&quot;frame/2&quot;).set_hidden(true)<br />		get_node(&quot;frame/3&quot;).set_hidden(true)<br />	elif tab == 2:<br />		get_node(&quot;layer/prev&quot;).show()<br />		get_node(&quot;layer/next&quot;).show()<br />		get_node(&quot;frame/1&quot;).set_hidden(true)<br />		get_node(&quot;frame/2&quot;).set_hidden(false)<br />		get_node(&quot;frame/3&quot;).set_hidden(true)<br />	elif tab == 3:<br />		get_node(&quot;layer/next&quot;).hide()<br />		get_node(&quot;frame/1&quot;).set_hidden(true)<br />		get_node(&quot;frame/2&quot;).set_hidden(true)<br />		get_node(&quot;frame/3&quot;).set_hidden(false)<br /><br />func _on_back_pressed():<br />	get_node(&quot;/root/global&quot;).goto_scene(&quot;res://game/ui/title-screen.scn&quot;)<br /><br /><br />func _on_prev_pressed():<br />	tab = tab - 1<br /><br /><br />func _on_next_pressed():<br />	tab = tab + 1<br /><br /><br />func _ready():<br />	# Called every time the node is added to the scene.<br />	# Initialization here<br />	set_process(true)

Comments

  • MegalomaniakMegalomaniak Posts: 1,001Admin
    Well, I'm not using texturebutton, but I have made something similar I guess:<br />
    optionsmenu.png[size=10pt]<br />Note that 'ContextSelection' is a HButtonArray(Count:3, Align: 'End')[/size]
    <br /><br />
    <br /><br />extends VBoxContainer<br /><br />var context<br /><br />func _init():<br />	context = &quot;Gameplay&quot;<br />	<br /><br />func _ready():<br />	var global = get_node(&quot;/root/global&quot;)<br />	set_process(true)<br />	set_process_input(true)<br />	Set_Context()<br />	<br /><br />func _input(event):<br />	if(event.is_pressed()):<br />		if(event.is_action(&quot;ui_cancel&quot;)):<br />			global.setScene(&quot;res://startScene.scn&quot;)<br />	<br /><br />func _on_BackButton_pressed():<br />	global.setScene(&quot;res://startScene.scn&quot;)<br />	<br /><br />func Get_Context( button ):<br />	if button == 0:<br />		context = &quot;Gameplay&quot;<br />		_ready()<br />	elif button == 1:<br />		context = &quot;Sound&quot;<br />		_ready()<br />	else:<br />		context = &quot;Graphics&quot;<br />		_ready()<br />	<br /><br />func Set_Context():<br />	if context == &quot;Gameplay&quot;:<br />		get_node(&quot;Editor/Context/Sound&quot;).hide()<br />		get_node(&quot;Editor/Context/Graphics&quot;).hide()<br />		get_node(&quot;Editor/Context/Gameplay&quot;).show()<br />	elif context == &quot;Sound&quot;:<br />		get_node(&quot;Editor/Context/Gameplay&quot;).hide()<br />		get_node(&quot;Editor/Context/Graphics&quot;).hide()<br />		get_node(&quot;Editor/Context/Sound&quot;).show()<br />	elif context == &quot;Graphics&quot;:<br />		get_node(&quot;Editor/Context/Gameplay&quot;).hide()<br />		get_node(&quot;Editor/Context/Sound&quot;).hide()<br />		get_node(&quot;Editor/Context/Graphics&quot;).show()<br /><br /><br />
    
  • yursan9yursan9 Posts: 6Member
    Thank you! I'll try it...  :)
  • MegalomaniakMegalomaniak Posts: 1,001Admin
    Right, just in case you copy-paste the code: know that [tt]func Get_Context( Button ):[/tt] is a signal from the HButtonArray(named ContextSelection in screenshot/Scene tree).
Sign In or Register to comment.