mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-08 00:40:08 +01:00
Add a main screen plugin to the plugin demos
This commit is contained in:
11
plugins/addons/main_screen/README.md
Normal file
11
plugins/addons/main_screen/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Main Screen Plugin Demo
|
||||
|
||||
This plugin demo shows how to make a main screen plugin.
|
||||
The main screen appears as a button next to the "2D", "3D", "Script", and
|
||||
"AssetLib" buttons. It also shows up when a Node it `handles` is selected.
|
||||
|
||||
For more information, see this documentation article:
|
||||
https://docs.godotengine.org/en/latest/tutorials/plugins/editor/making_main_screen_plugins.html
|
||||
|
||||
If you would like to see a more complete example of what main screen plugins
|
||||
are capable of, check out the [2.5D demo project](../../../misc/2.5d).
|
||||
1
plugins/addons/main_screen/handled_by_main_screen.gd
Normal file
1
plugins/addons/main_screen/handled_by_main_screen.gd
Normal file
@@ -0,0 +1 @@
|
||||
extends Node
|
||||
20
plugins/addons/main_screen/main_panel.tscn
Normal file
20
plugins/addons/main_screen/main_panel.tscn
Normal file
@@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/main_screen/print_hello.gd" type="Script" id=1]
|
||||
|
||||
[node name="MainPanel" type="CenterContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PrintHello" type="Button" parent="."]
|
||||
margin_left = 472.0
|
||||
margin_top = 290.0
|
||||
margin_right = 552.0
|
||||
margin_bottom = 310.0
|
||||
text = "Print Hello"
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
[connection signal="pressed" from="PrintHello" to="PrintHello" method="_on_PrintHello_pressed"]
|
||||
41
plugins/addons/main_screen/main_screen_plugin.gd
Normal file
41
plugins/addons/main_screen/main_screen_plugin.gd
Normal file
@@ -0,0 +1,41 @@
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
const MainPanel = preload("res://addons/main_screen/main_panel.tscn")
|
||||
|
||||
var main_panel_instance
|
||||
|
||||
func _enter_tree():
|
||||
main_panel_instance = MainPanel.instance()
|
||||
# Add the main panel to the editor's main viewport.
|
||||
get_editor_interface().get_editor_viewport().add_child(main_panel_instance)
|
||||
# Hide the main panel. Very much required.
|
||||
make_visible(false)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
if main_panel_instance:
|
||||
main_panel_instance.queue_free()
|
||||
|
||||
|
||||
func has_main_screen():
|
||||
return true
|
||||
|
||||
|
||||
func make_visible(visible):
|
||||
if main_panel_instance:
|
||||
main_panel_instance.visible = visible
|
||||
|
||||
|
||||
# If your plugin doesn't handle any node types, you can remove this method.
|
||||
func handles(obj):
|
||||
return obj is preload("res://addons/main_screen/handled_by_main_screen.gd")
|
||||
|
||||
|
||||
func get_plugin_name():
|
||||
return "Main Screen Plugin"
|
||||
|
||||
|
||||
func get_plugin_icon():
|
||||
# Must return some kind of Texture for the icon.
|
||||
return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons")
|
||||
7
plugins/addons/main_screen/plugin.cfg
Normal file
7
plugins/addons/main_screen/plugin.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Main Screen Plugin Demo"
|
||||
description="Demonstrates how to make a main screen plugin."
|
||||
author="Aaron Franke, Julian Murgia"
|
||||
version="1.0"
|
||||
script="main_screen_plugin.gd"
|
||||
5
plugins/addons/main_screen/print_hello.gd
Normal file
5
plugins/addons/main_screen/print_hello.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
tool
|
||||
extends Button
|
||||
|
||||
func _on_PrintHello_pressed():
|
||||
print("Hello from the main screen plugin!")
|
||||
Reference in New Issue
Block a user