44 lines
916 B
GDScript
44 lines
916 B
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
|
|
|
|
m.owner = self
|
|
m.position.x = 1.5 * get_child_count(true)
|