Test procedural mesh generation
This commit is contained in:
1 parent
3187c3d359
commit
2c01143579
8 files changed
+154
-1
No files matched your search
@@ -0,0 +1,49 @@
|
||||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
var editor_button_plugin:EditorButtonPlugin
|
||||
|
||||
func _enter_tree() -> void:
|
||||
print("[inspector_buttons] enter")
|
||||
editor_button_plugin = EditorButtonPlugin.new()
|
||||
add_inspector_plugin(editor_button_plugin)
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if is_instance_valid(editor_button_plugin):
|
||||
print("[inspector_buttons] exit")
|
||||
remove_inspector_plugin(editor_button_plugin)
|
||||
editor_button_plugin = null
|
||||
|
||||
|
||||
class EditorButtonPlugin extends EditorInspectorPlugin:
|
||||
func _can_handle(object: Object) -> bool:
|
||||
return object.has_method('_add_inspector_buttons')
|
||||
|
||||
|
||||
func _parse_begin(object: Object) -> void:
|
||||
var buttons_data = object._add_inspector_buttons()
|
||||
for button_data in buttons_data:
|
||||
var name = button_data.get("name", null)
|
||||
var icon = button_data.get("icon", null)
|
||||
var pressed = button_data.get("pressed", null)
|
||||
if not name:
|
||||
push_warning('_add_inspector_buttons(): A button does not have a name key. Defaulting to: "Button"')
|
||||
name = "Button"
|
||||
if icon and not icon is Texture:
|
||||
push_warning('_add_inspector_buttons(): The button <{name}> icon is not a texture.'.format({"name":name}))
|
||||
icon = null
|
||||
if not pressed:
|
||||
push_warning('_add_inspector_buttons(): The button <{name}> does not have a pressed key. Skipping.'.format({"name":name}))
|
||||
continue
|
||||
if not pressed is Callable:
|
||||
push_warning('_add_inspector_buttons(): The button <{name}> pressed is not a Callable. Skipping.'.format({"name":name}))
|
||||
continue
|
||||
|
||||
var button = Button.new()
|
||||
button.text = name
|
||||
if icon:
|
||||
button.icon = icon
|
||||
button.expand_icon = true
|
||||
button.pressed.connect(pressed)
|
||||
add_custom_control(button)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cmkf6s21ky7b5
|
||||
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Inspector Buttons"
|
||||
description="Quick and dirty Godot inspector plugins. Taken from the internets"
|
||||
author="mrcdk"
|
||||
version="0.1"
|
||||
script="inspector_buttons.gd"
|
||||
Reference in new issue
Block a user