TD-37: Fix Scene Switching Script
This commit is contained in:
parent
6659875c65
commit
8b3f5e9ad1
3 changed files with 11 additions and 8 deletions
|
@ -1,8 +1,7 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bqfijb7bk2g7j"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bqfijb7bk2g7j"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bt4hxdwromnxs" path="res://ui/theme.tres" id="1_6qgep"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/switch_to_scene.gd" id="2_c477a"]
|
||||
[ext_resource type="PackedScene" uid="uid://ctqxikky2g0nj" path="res://scenes/theme_test.tscn" id="3_j7pbg"]
|
||||
|
||||
[node name="Root" type="Panel"]
|
||||
anchors_preset = 15
|
||||
|
@ -40,4 +39,4 @@ autowrap_mode = 0
|
|||
layout_mode = 2
|
||||
text = "Theme Test Scene"
|
||||
script = ExtResource("2_c477a")
|
||||
scene = ExtResource("3_j7pbg")
|
||||
scene_name = "theme_test"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://ctqxikky2g0nj"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://ctqxikky2g0nj"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/ui/switch_to_scene.gd" id="1_7goww"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/websocket_time.gd" id="1_qy4dl"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ujhhp"]
|
||||
|
@ -1577,7 +1578,9 @@ size_flags_vertical = 3
|
|||
|
||||
[node name="Button" type="Button" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Just a Button"
|
||||
text = "Back to Main Menu"
|
||||
script = ExtResource("1_7goww")
|
||||
scene_name = "main_menu"
|
||||
|
||||
[node name="ToggleButton" type="Button" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extends Button
|
||||
|
||||
@export var scene: PackedScene
|
||||
@export var scene_name: String
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -8,6 +8,7 @@ func _ready() -> void:
|
|||
|
||||
|
||||
func _on_Button_pressed() -> void:
|
||||
if not scene:
|
||||
if not scene_name:
|
||||
push_error("Scene to switch to is not configured")
|
||||
get_tree().change_scene_to_packed(scene)
|
||||
return
|
||||
get_tree().change_scene_to_file("res://scenes/" + scene_name + ".tscn")
|
||||
|
|
Loading…
Add table
Reference in a new issue