Browse Source

Slightly improve the GUI in 3D demo

Aaron Franke 5 years ago
parent
commit
cb5906aea3

+ 2 - 4
viewport/gui_in_3d/gui_3d.gd

@@ -1,5 +1,5 @@
 extends Spatial
 extends Spatial
-# Member variables
+
 # The size of the quad mesh itself.
 # The size of the quad mesh itself.
 var quad_mesh_size
 var quad_mesh_size
 # Used for checking if the mouse is inside the Area
 # Used for checking if the mouse is inside the Area
@@ -10,12 +10,11 @@ var is_mouse_held = false
 var last_mouse_pos3D = null
 var last_mouse_pos3D = null
 # The last processed input touch/mouse event. To calculate relative movement.
 # The last processed input touch/mouse event. To calculate relative movement.
 var last_mouse_pos2D = null
 var last_mouse_pos2D = null
-# Most used nodes
+
 onready var node_viewport = $Viewport
 onready var node_viewport = $Viewport
 onready var node_quad = $Quad
 onready var node_quad = $Quad
 onready var node_area = $Quad/Area
 onready var node_area = $Quad/Area
 
 
-
 func _ready():
 func _ready():
 	node_area.connect("mouse_entered", self, "_mouse_entered_area")
 	node_area.connect("mouse_entered", self, "_mouse_entered_area")
 	
 	
@@ -169,4 +168,3 @@ func rotate_area_to_billboard():
 		
 		
 		# Rotate in the Z axis to compensate camera tilt
 		# Rotate in the Z axis to compensate camera tilt
 		node_area.rotate_object_local(Vector3.BACK, camera.rotation.z)
 		node_area.rotate_object_local(Vector3.BACK, camera.rotation.z)
-

+ 22 - 57
viewport/gui_in_3d/gui_in_3d.tscn

@@ -1,6 +1,6 @@
-[gd_scene load_steps=10 format=2]
+[gd_scene load_steps=6 format=2]
 
 
-[ext_resource path="res://view_gui.tscn" type="PackedScene" id=1]
+[ext_resource path="res://gui_panel_3d.tscn" type="PackedScene" id=1]
 
 
 [sub_resource type="Animation" id=1]
 [sub_resource type="Animation" id=1]
 length = 6.0
 length = 6.0
@@ -20,43 +20,15 @@ tracks/0/keys = {
 
 
 [sub_resource type="PlaneMesh" id=2]
 [sub_resource type="PlaneMesh" id=2]
 
 
-[sub_resource type="GDScript" id=3]
-script/source = "tool
-extends Object
-func e():
-	return 0
-"
-
-[sub_resource type="GDScript" id=4]
-script/source = "tool
-extends Object
-func e():
-	return 90
-"
-
-[sub_resource type="GDScript" id=5]
-script/source = "tool
-extends Object
-func e():
-	return 0
-"
-
-[sub_resource type="CubeMesh" id=6]
-
-[sub_resource type="SpatialMaterial" id=7]
+[sub_resource type="CubeMesh" id=3]
+
+[sub_resource type="SpatialMaterial" id=4]
 albedo_color = Color( 0.722656, 0.791992, 1, 1 )
 albedo_color = Color( 0.722656, 0.791992, 1, 1 )
 roughness = 0.0
 roughness = 0.0
 
 
-[sub_resource type="GDScript" id=8]
-script/source = "tool
-extends Object
-func e():
-	return 0
-"
-
-[node name="gui_in_3d" type="Spatial"]
+[node name="GUIin3D" type="Spatial"]
 
 
-[node name="view_gui" parent="." instance=ExtResource( 1 )]
+[node name="GUIPanel3D" parent="." instance=ExtResource( 1 )]
 
 
 [node name="Camera" type="Camera" parent="."]
 [node name="Camera" type="Camera" parent="."]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 3 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 3 )
@@ -73,46 +45,39 @@ autoplay = "Move_camera"
 playback_speed = 0.25
 playback_speed = 0.25
 anims/Move_camera = SubResource( 1 )
 anims/Move_camera = SubResource( 1 )
 
 
-[node name="3D_background" type="Spatial" parent="."]
+[node name="Background" type="Spatial" parent="."]
 
 
-[node name="Wall" type="MeshInstance" parent="3D_background"]
-transform = Transform( 4, 0, 0, 0, -1.74846e-007, -4, 0, 4, -1.74846e-007, -2.60819, 0.589247, -2.08943 )
+[node name="Wall" type="MeshInstance" parent="Background"]
+transform = Transform( 4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, -2.60819, 0.589247, -2.08943 )
 mesh = SubResource( 2 )
 mesh = SubResource( 2 )
 material/0 = null
 material/0 = null
-script = SubResource( 3 )
 
 
-[node name="Wall2" type="MeshInstance" parent="3D_background"]
-transform = Transform( 4, 0, 0, 0, -1.74846e-007, -4, 0, 4, -1.74846e-007, 5.08055, 0.589247, -2.08943 )
+[node name="Wall2" type="MeshInstance" parent="Background"]
+transform = Transform( 4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, 5.08055, 0.589247, -2.08943 )
 mesh = SubResource( 2 )
 mesh = SubResource( 2 )
 material/0 = null
 material/0 = null
-script = SubResource( 3 )
 
 
-[node name="Wall3" type="MeshInstance" parent="3D_background"]
-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 )
+[node name="Wall3" type="MeshInstance" parent="Background"]
+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 )
 mesh = SubResource( 2 )
 mesh = SubResource( 2 )
 material/0 = null
 material/0 = null
-script = SubResource( 4 )
 
 
-[node name="Floor" type="MeshInstance" parent="3D_background"]
+[node name="Floor" type="MeshInstance" parent="Background"]
 transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, -2.60819, -2.68765, 1.46502 )
 transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, -2.60819, -2.68765, 1.46502 )
 mesh = SubResource( 2 )
 mesh = SubResource( 2 )
 material/0 = null
 material/0 = null
-script = SubResource( 5 )
 
 
-[node name="Floor2" type="MeshInstance" parent="3D_background"]
+[node name="Floor2" type="MeshInstance" parent="Background"]
 transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 5.08055, -2.68765, 1.46502 )
 transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 5.08055, -2.68765, 1.46502 )
 mesh = SubResource( 2 )
 mesh = SubResource( 2 )
 material/0 = null
 material/0 = null
-script = SubResource( 5 )
 
 
-[node name="Cube" type="MeshInstance" parent="3D_background"]
+[node name="Cube" type="MeshInstance" parent="Background"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.25901, -0.598608, 0.374871 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.25901, -0.598608, 0.374871 )
-mesh = SubResource( 6 )
-material/0 = SubResource( 7 )
-script = SubResource( 8 )
+mesh = SubResource( 3 )
+material/0 = SubResource( 4 )
 
 
-[node name="Cube2" type="MeshInstance" parent="3D_background"]
+[node name="Cube2" type="MeshInstance" parent="Background"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.88761, 2.01326, 0.374871 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.88761, 2.01326, 0.374871 )
-mesh = SubResource( 6 )
-material/0 = SubResource( 7 )
-script = SubResource( 8 )
+mesh = SubResource( 3 )
+material/0 = SubResource( 4 )

+ 2 - 3
viewport/gui_in_3d/view_gui.tscn → viewport/gui_in_3d/gui_panel_3d.tscn

@@ -19,7 +19,7 @@ albedo_texture = SubResource( 2 )
 [sub_resource type="BoxShape" id=4]
 [sub_resource type="BoxShape" id=4]
 extents = Vector3( 1.5, 1, 0.05 )
 extents = Vector3( 1.5, 1, 0.05 )
 
 
-[node name="GUI_3D" type="Spatial"]
+[node name="GUIPanel3D" type="Spatial"]
 script = ExtResource( 1 )
 script = ExtResource( 1 )
 
 
 [node name="Viewport" type="Viewport" parent="."]
 [node name="Viewport" type="Viewport" parent="."]
@@ -89,7 +89,6 @@ margin_left = 260.0
 margin_top = 26.0
 margin_top = 26.0
 margin_right = 276.0
 margin_right = 276.0
 margin_bottom = 166.0
 margin_bottom = 166.0
-ticks_on_borders = false
 
 
 [node name="OptionButton" type="OptionButton" parent="Viewport/GUI/Panel"]
 [node name="OptionButton" type="OptionButton" parent="Viewport/GUI/Panel"]
 margin_left = 170.0
 margin_left = 170.0
@@ -97,7 +96,7 @@ margin_top = 111.0
 margin_right = 252.0
 margin_right = 252.0
 margin_bottom = 165.0
 margin_bottom = 165.0
 text = "Item 0"
 text = "Item 0"
-items = [ "Item 0", null, false, -1, null, "Item 1", null, false, -1, null, "Item 2", null, false, -1, null ]
+items = [ "Item 0", null, false, 0, null, "Item 1", null, false, 1, null, "Item 2", null, false, 2, null ]
 selected = 0
 selected = 0
 
 
 [node name="Quad" type="MeshInstance" parent="."]
 [node name="Quad" type="MeshInstance" parent="."]