Skip to content

Commit cb5906a

Browse files
committed
Slightly improve the GUI in 3D demo
1 parent 237a865 commit cb5906a

File tree

3 files changed

+26
-64
lines changed

3 files changed

+26
-64
lines changed

viewport/gui_in_3d/gui_3d.gd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
extends Spatial
2-
# Member variables
2+
33
# The size of the quad mesh itself.
44
var quad_mesh_size
55
# Used for checking if the mouse is inside the Area
@@ -10,12 +10,11 @@ var is_mouse_held = false
1010
var last_mouse_pos3D = null
1111
# The last processed input touch/mouse event. To calculate relative movement.
1212
var last_mouse_pos2D = null
13-
# Most used nodes
13+
1414
onready var node_viewport = $Viewport
1515
onready var node_quad = $Quad
1616
onready var node_area = $Quad/Area
1717

18-
1918
func _ready():
2019
node_area.connect("mouse_entered", self, "_mouse_entered_area")
2120

@@ -169,4 +168,3 @@ func rotate_area_to_billboard():
169168

170169
# Rotate in the Z axis to compensate camera tilt
171170
node_area.rotate_object_local(Vector3.BACK, camera.rotation.z)
172-

viewport/gui_in_3d/gui_in_3d.tscn

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[gd_scene load_steps=10 format=2]
1+
[gd_scene load_steps=6 format=2]
22

3-
[ext_resource path="res://view_gui.tscn" type="PackedScene" id=1]
3+
[ext_resource path="res://gui_panel_3d.tscn" type="PackedScene" id=1]
44

55
[sub_resource type="Animation" id=1]
66
length = 6.0
@@ -20,43 +20,15 @@ tracks/0/keys = {
2020

2121
[sub_resource type="PlaneMesh" id=2]
2222

23-
[sub_resource type="GDScript" id=3]
24-
script/source = "tool
25-
extends Object
26-
func e():
27-
return 0
28-
"
29-
30-
[sub_resource type="GDScript" id=4]
31-
script/source = "tool
32-
extends Object
33-
func e():
34-
return 90
35-
"
36-
37-
[sub_resource type="GDScript" id=5]
38-
script/source = "tool
39-
extends Object
40-
func e():
41-
return 0
42-
"
43-
44-
[sub_resource type="CubeMesh" id=6]
45-
46-
[sub_resource type="SpatialMaterial" id=7]
23+
[sub_resource type="CubeMesh" id=3]
24+
25+
[sub_resource type="SpatialMaterial" id=4]
4726
albedo_color = Color( 0.722656, 0.791992, 1, 1 )
4827
roughness = 0.0
4928

50-
[sub_resource type="GDScript" id=8]
51-
script/source = "tool
52-
extends Object
53-
func e():
54-
return 0
55-
"
56-
57-
[node name="gui_in_3d" type="Spatial"]
29+
[node name="GUIin3D" type="Spatial"]
5830

59-
[node name="view_gui" parent="." instance=ExtResource( 1 )]
31+
[node name="GUIPanel3D" parent="." instance=ExtResource( 1 )]
6032

6133
[node name="Camera" type="Camera" parent="."]
6234
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 3 )
@@ -73,46 +45,39 @@ autoplay = "Move_camera"
7345
playback_speed = 0.25
7446
anims/Move_camera = SubResource( 1 )
7547

76-
[node name="3D_background" type="Spatial" parent="."]
48+
[node name="Background" type="Spatial" parent="."]
7749

78-
[node name="Wall" type="MeshInstance" parent="3D_background"]
79-
transform = Transform( 4, 0, 0, 0, -1.74846e-007, -4, 0, 4, -1.74846e-007, -2.60819, 0.589247, -2.08943 )
50+
[node name="Wall" type="MeshInstance" parent="Background"]
51+
transform = Transform( 4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, -2.60819, 0.589247, -2.08943 )
8052
mesh = SubResource( 2 )
8153
material/0 = null
82-
script = SubResource( 3 )
8354

84-
[node name="Wall2" type="MeshInstance" parent="3D_background"]
85-
transform = Transform( 4, 0, 0, 0, -1.74846e-007, -4, 0, 4, -1.74846e-007, 5.08055, 0.589247, -2.08943 )
55+
[node name="Wall2" type="MeshInstance" parent="Background"]
56+
transform = Transform( 4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, 5.08055, 0.589247, -2.08943 )
8657
mesh = SubResource( 2 )
8758
material/0 = null
88-
script = SubResource( 3 )
8959

90-
[node name="Wall3" type="MeshInstance" parent="3D_background"]
91-
transform = Transform( -1.74846e-007, -4, 0, -1.74846e-007, 7.64274e-015, -4, 4, -1.74846e-007, -1.74846e-007, 9.04446, 0.589247, 1.62058 )
60+
[node name="Wall3" type="MeshInstance" parent="Background"]
61+
transform = Transform( -1.74846e-07, -4, 0, -1.74846e-07, 7.64274e-15, -4, 4, -1.74846e-07, -1.74846e-07, 9.04446, 0.589247, 1.62058 )
9262
mesh = SubResource( 2 )
9363
material/0 = null
94-
script = SubResource( 4 )
9564

96-
[node name="Floor" type="MeshInstance" parent="3D_background"]
65+
[node name="Floor" type="MeshInstance" parent="Background"]
9766
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, -2.60819, -2.68765, 1.46502 )
9867
mesh = SubResource( 2 )
9968
material/0 = null
100-
script = SubResource( 5 )
10169

102-
[node name="Floor2" type="MeshInstance" parent="3D_background"]
70+
[node name="Floor2" type="MeshInstance" parent="Background"]
10371
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 5.08055, -2.68765, 1.46502 )
10472
mesh = SubResource( 2 )
10573
material/0 = null
106-
script = SubResource( 5 )
10774

108-
[node name="Cube" type="MeshInstance" parent="3D_background"]
75+
[node name="Cube" type="MeshInstance" parent="Background"]
10976
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.25901, -0.598608, 0.374871 )
110-
mesh = SubResource( 6 )
111-
material/0 = SubResource( 7 )
112-
script = SubResource( 8 )
77+
mesh = SubResource( 3 )
78+
material/0 = SubResource( 4 )
11379

114-
[node name="Cube2" type="MeshInstance" parent="3D_background"]
80+
[node name="Cube2" type="MeshInstance" parent="Background"]
11581
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.88761, 2.01326, 0.374871 )
116-
mesh = SubResource( 6 )
117-
material/0 = SubResource( 7 )
118-
script = SubResource( 8 )
82+
mesh = SubResource( 3 )
83+
material/0 = SubResource( 4 )

viewport/gui_in_3d/view_gui.tscn renamed to viewport/gui_in_3d/gui_panel_3d.tscn

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ albedo_texture = SubResource( 2 )
1919
[sub_resource type="BoxShape" id=4]
2020
extents = Vector3( 1.5, 1, 0.05 )
2121

22-
[node name="GUI_3D" type="Spatial"]
22+
[node name="GUIPanel3D" type="Spatial"]
2323
script = ExtResource( 1 )
2424

2525
[node name="Viewport" type="Viewport" parent="."]
@@ -89,15 +89,14 @@ margin_left = 260.0
8989
margin_top = 26.0
9090
margin_right = 276.0
9191
margin_bottom = 166.0
92-
ticks_on_borders = false
9392

9493
[node name="OptionButton" type="OptionButton" parent="Viewport/GUI/Panel"]
9594
margin_left = 170.0
9695
margin_top = 111.0
9796
margin_right = 252.0
9897
margin_bottom = 165.0
9998
text = "Item 0"
100-
items = [ "Item 0", null, false, -1, null, "Item 1", null, false, -1, null, "Item 2", null, false, -1, null ]
99+
items = [ "Item 0", null, false, 0, null, "Item 1", null, false, 1, null, "Item 2", null, false, 2, null ]
101100
selected = 0
102101

103102
[node name="Quad" type="MeshInstance" parent="."]

0 commit comments

Comments
 (0)