|
|
|
@tool
|
|
|
|
extends EditorPlugin
|
|
|
|
|
|
|
|
const CONTAINER := CustomControlContainer.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT
|
|
|
|
|
|
|
|
var controls: Control = null;
|
|
|
|
|
|
|
|
func _handles(object: Object) -> bool:
|
|
|
|
var script := object.get_script() as CSharpScript
|
|
|
|
return script and script.resource_path.ends_with("/Terrain.cs")
|
|
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
|
|
if not controls: return
|
|
|
|
if controls.get_parent():
|
|
|
|
remove_control_from_container(CONTAINER, controls)
|
|
|
|
controls.free()
|
|
|
|
|
|
|
|
func _make_visible(visible: bool) -> void:
|
|
|
|
if visible:
|
|
|
|
if not controls:
|
|
|
|
var controls_scene = load("res://terrain/editing/TerrainEditingControls.tscn")
|
|
|
|
controls = controls_scene.instantiate()
|
|
|
|
controls.EditorUndoRedo = get_undo_redo()
|
|
|
|
add_control_to_container(CONTAINER, controls)
|
|
|
|
elif controls and controls.get_parent():
|
|
|
|
remove_control_from_container(CONTAINER, controls)
|