49 lines
1.1 KiB
GDScript
49 lines
1.1 KiB
GDScript
@tool
|
|
extends Node3D
|
|
|
|
|
|
|
|
func _add_inspector_buttons() -> Array:
|
|
var buttons: Array = []
|
|
|
|
buttons.push_back({
|
|
"name": "Regular cube mesh",
|
|
"pressed": _add_regular_cube_mesh
|
|
})
|
|
buttons.push_back({
|
|
"name": "Internal cube mesh",
|
|
"pressed": _add_internal_cube_mesh
|
|
})
|
|
buttons.push_back({
|
|
"name": "Delete all children",
|
|
"pressed": func(): for child in get_children(true): child.queue_free()
|
|
})
|
|
|
|
return buttons
|
|
|
|
func _add_regular_cube_mesh() -> void:
|
|
var m = MeshInstance3D.new()
|
|
var b = BoxMesh.new()
|
|
m.mesh = b
|
|
add_child(m, true)
|
|
m.owner = self
|
|
m.position.x = 1.5 * get_child_count(true)
|
|
|
|
func _add_internal_cube_mesh() -> void:
|
|
var m = MeshInstance3D.new()
|
|
var b = BoxMesh.new()
|
|
m.mesh = b
|
|
add_child(m, true, Node.INTERNAL_MODE_BACK)
|
|
|
|
var mat = StandardMaterial3D.new()
|
|
mat.albedo_color = Color("ff4c4e")
|
|
b.material = mat
|
|
|
|
# Lock the node in editor. Prevents selection (here for internal nodes)
|
|
# UNDOCUMENTED
|
|
# https://github.com/godotengine/godot-proposals/issues/3046
|
|
m.set_meta("_edit_lock_", true)
|
|
|
|
m.owner = self
|
|
m.position.x = 1.5 * get_child_count(true)
|