@ -1,39 +0,0 @@ |
|||||||
#if TOOLS |
|
||||||
[Tool] |
|
||||||
public partial class TerrainEditingPlugin |
|
||||||
: EditorPlugin |
|
||||||
{ |
|
||||||
const string ScenePath = "res://addons/terrain-editing/TerrainEditingControls.tscn"; |
|
||||||
// The container to which the editing controls get added to when Terrain is selected. |
|
||||||
const CustomControlContainer Container = CustomControlContainer.SpatialEditorSideRight; |
|
||||||
|
|
||||||
|
|
||||||
TerrainEditingControls _controls; |
|
||||||
|
|
||||||
public override bool _Handles(GodotObject obj) |
|
||||||
=> obj is Terrain; |
|
||||||
|
|
||||||
public override void _EnterTree() |
|
||||||
{ |
|
||||||
var scene = GD.Load<PackedScene>(ScenePath); |
|
||||||
_controls = scene.Instantiate<TerrainEditingControls>(); |
|
||||||
} |
|
||||||
|
|
||||||
public override void _ExitTree() |
|
||||||
{ |
|
||||||
if (_controls == null) return; |
|
||||||
if (_controls.GetParent() != null) |
|
||||||
RemoveControlFromContainer(Container, _controls); |
|
||||||
_controls.Free(); |
|
||||||
_controls = null; |
|
||||||
} |
|
||||||
|
|
||||||
public override void _MakeVisible(bool visible) |
|
||||||
{ |
|
||||||
if (visible) |
|
||||||
AddControlToContainer(Container, _controls); |
|
||||||
else if (_controls.GetParent() != null) |
|
||||||
RemoveControlFromContainer(Container, _controls); |
|
||||||
} |
|
||||||
} |
|
||||||
#endif |
|
@ -0,0 +1,26 @@ |
|||||||
|
@tool |
||||||
|
extends EditorPlugin |
||||||
|
|
||||||
|
const CONTAINER := CustomControlContainer.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT |
||||||
|
|
||||||
|
var controls_scene := preload("res://terrain/editing/TerrainEditingControls.tscn") |
||||||
|
var controls_script := preload("res://terrain/editing/TerrainEditingControls.cs") |
||||||
|
|
||||||
|
var controls : Control; |
||||||
|
|
||||||
|
func _handles(object: Object) -> bool: |
||||||
|
return object.get_script() == controls_script |
||||||
|
|
||||||
|
func _enter_tree() -> void: |
||||||
|
controls = controls_scene.instantiate() |
||||||
|
|
||||||
|
func _exit_tree() -> void: |
||||||
|
if controls.get_parent(): |
||||||
|
remove_control_from_container(CONTAINER, controls) |
||||||
|
controls.free() |
||||||
|
|
||||||
|
func _make_visible(visible: bool) -> void: |
||||||
|
if visible: |
||||||
|
add_control_to_container(CONTAINER, controls) |
||||||
|
elif controls.get_parent(): |
||||||
|
remove_control_from_container(CONTAINER, controls) |
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 168 B After Width: | Height: | Size: 168 B |
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 147 B |
@ -1,12 +1,11 @@ |
|||||||
[gd_scene load_steps=15 format=3 uid="uid://bmljchm3fj42"] |
[gd_scene load_steps=15 format=3 uid="uid://bmljchm3fj42"] |
||||||
|
|
||||||
[ext_resource type="Script" path="res://addons/terrain-editing/TerrainEditingControls.cs" id="1_fklx3"] |
[ext_resource type="Script" path="res://terrain/editing/TerrainEditingControls.cs" id="1_fklx3"] |
||||||
[ext_resource type="Texture2D" uid="uid://btl3jsqeldix2" path="res://addons/terrain-editing/icons/corner.png" id="1_w5qr7"] |
[ext_resource type="Texture2D" uid="uid://btl3jsqeldix2" path="res://assets/textures/terrain/editing/corner.png" id="1_w5qr7"] |
||||||
[ext_resource type="Texture2D" uid="uid://dqbtbf8pe05qv" path="res://addons/terrain-editing/icons/height.png" id="2_hrmm4"] |
[ext_resource type="Texture2D" uid="uid://dqbtbf8pe05qv" path="res://assets/textures/terrain/editing/height.png" id="2_hrmm4"] |
||||||
[ext_resource type="Texture2D" uid="uid://2u1ldmh0osbx" path="res://addons/terrain-editing/icons/circle.png" id="2_yvc34"] |
[ext_resource type="Texture2D" uid="uid://2u1ldmh0osbx" path="res://assets/textures/terrain/editing/circle.png" id="2_yvc34"] |
||||||
[ext_resource type="Texture2D" uid="uid://btdpyu4n3pgkx" path="res://addons/terrain-editing/icons/paint.png" id="3_5x55r"] |
[ext_resource type="Texture2D" uid="uid://btdpyu4n3pgkx" path="res://assets/textures/terrain/editing/paint.png" id="3_5x55r"] |
||||||
[ext_resource type="Texture2D" uid="uid://btjd1704xtdjv" path="res://addons/terrain-editing/icons/square.png" id="3_aaaoe"] |
[ext_resource type="Texture2D" uid="uid://btjd1704xtdjv" path="res://assets/textures/terrain/editing/square.png" id="3_aaaoe"] |
||||||
|
|
||||||
[ext_resource type="Image" uid="uid://b0jp1dyxugbr7" path="res://assets/textures/terrain/grass.png" id="Image_d41co"] |
[ext_resource type="Image" uid="uid://b0jp1dyxugbr7" path="res://assets/textures/terrain/grass.png" id="Image_d41co"] |
||||||
[ext_resource type="Image" uid="uid://bpo7mkr6sctqr" path="res://assets/textures/terrain/dirt.png" id="Image_y3rra"] |
[ext_resource type="Image" uid="uid://bpo7mkr6sctqr" path="res://assets/textures/terrain/dirt.png" id="Image_y3rra"] |
||||||
[ext_resource type="Image" uid="uid://dqyqg6yt7yk3k" path="res://assets/textures/terrain/rock.png" id="Image_x8cdn"] |
[ext_resource type="Image" uid="uid://dqyqg6yt7yk3k" path="res://assets/textures/terrain/rock.png" id="Image_x8cdn"] |