Files
godot-demo-projects/viewport/gui_in_3d/gui_panel_3d.tscn
David Briscoe c49e134e13 Explain how to setup GUI in 3D (#1149)
Make it more obvious to newcomers how this demo works so they can
replicate it in their projects.

Change the text to point to how this is working.

Add Editor Descriptions to make it clearer how this is setup.

Co-authored-by: Aaron Franke <arnfranke@yahoo.com>
2024-12-23 18:55:20 +01:00

150 lines
3.9 KiB
Plaintext

[gd_scene load_steps=7 format=3 uid="uid://dvl383ispakmn"]
[ext_resource type="Script" path="res://gui_3d.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://brwp8bimc75uu" path="res://icon.webp" id="2"]
[sub_resource type="QuadMesh" id="1"]
size = Vector2(3, 2)
[sub_resource type="ViewportTexture" id="2"]
viewport_path = NodePath("SubViewport")
[sub_resource type="StandardMaterial3D" id="3"]
resource_local_to_scene = true
transparency = 1
shading_mode = 0
albedo_texture = SubResource("2")
[sub_resource type="BoxShape3D" id="4"]
size = Vector3(3, 2, 0.1)
[node name="GUIPanel3D" type="Node3D"]
process_mode = 3
script = ExtResource("1")
[node name="SubViewport" type="SubViewport" parent="."]
editor_description = "SubViewport contents can be displayed using a ViewportTexture."
gui_embed_subwindows = true
size = Vector2i(560, 360)
render_target_update_mode = 4
[node name="GUI" type="Control" parent="SubViewport"]
layout_mode = 3
anchors_preset = 0
offset_right = 560.0
offset_bottom = 360.0
mouse_filter = 1
[node name="Panel" type="Panel" parent="SubViewport/GUI"]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
[node name="VBoxContainer" type="VBoxContainer" parent="SubViewport/GUI/Panel"]
layout_mode = 1
anchors_preset = 9
anchor_bottom = 1.0
offset_left = 20.0
offset_top = 20.0
offset_right = 319.0
offset_bottom = -20.0
grow_vertical = 2
theme_override_constants/separation = 13
[node name="Label" type="Label" parent="SubViewport/GUI/Panel/VBoxContainer"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
text = "SubViewport is rendered on Quad"
horizontal_alignment = 1
autowrap_mode = 2
[node name="Button" type="Button" parent="SubViewport/GUI/Panel/VBoxContainer"]
layout_mode = 2
text = "A button!"
[node name="LineEdit" type="LineEdit" parent="SubViewport/GUI/Panel/VBoxContainer"]
layout_mode = 2
placeholder_text = "Enter text here..."
[node name="HSlider" type="HSlider" parent="SubViewport/GUI/Panel/VBoxContainer"]
layout_mode = 2
step = 0.0
ticks_on_borders = true
[node name="ColorRect" type="ColorRect" parent="SubViewport/GUI/Panel"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -182.0
offset_top = 16.0
offset_right = -54.0
offset_bottom = 144.0
grow_horizontal = 0
color = Color(1, 0, 0, 1)
[node name="TextureRect" type="TextureRect" parent="SubViewport/GUI/Panel"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -166.0
offset_top = 32.0
offset_right = -70.0
offset_bottom = 128.0
grow_horizontal = 0
texture = ExtResource("2")
expand_mode = 1
[node name="VSlider" type="VSlider" parent="SubViewport/GUI/Panel"]
layout_mode = 1
anchors_preset = 11
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -37.0
offset_top = 16.0
offset_right = -5.0
offset_bottom = -16.0
grow_horizontal = 0
grow_vertical = 2
step = 0.0
[node name="OptionButton" type="OptionButton" parent="SubViewport/GUI/Panel"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -227.0
offset_top = -208.0
offset_right = -39.0
offset_bottom = -147.0
grow_horizontal = 0
grow_vertical = 0
selected = 0
item_count = 3
popup/item_0/text = "Item 0"
popup/item_1/text = "Item 1"
popup/item_1/id = 1
popup/item_2/text = "Item 2"
popup/item_2/id = 2
[node name="Quad" type="MeshInstance3D" parent="."]
editor_description = "To setup this MeshInstance3D:
* Set Surface Material Override to a new StandardMaterial3D.
* At the bottom of the StandardMaterial3D's properties, set \"Local to Scene\" to true.
* Set the Albedo Texture of StandardMaterial3D to new ViewportTexture and set the Viewport Path.
* Transparency to Alpha.
* Shading to Unshaded."
mesh = SubResource("1")
surface_material_override/0 = SubResource("3")
[node name="Area3D" type="Area3D" parent="Quad"]
collision_layer = 2
input_capture_on_drag = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="Quad/Area3D"]
shape = SubResource("4")