Using @tool to create in-editor draggables in 2D

Godot Version




I’m working with a small team of non-programmers, like my level designer. I want to add some interface items for them in my scripts that run in-editor to set directions, ranges, heights and other behaviors of the level.

Is there some resources i can look at to draw, interact and set variables through methods that aren’t the inspector?

If i can learn how to draw a dot that can be dragged and referenced it’d would already change the world for me.

There’s probably not just one tutorial or resource for this.

So far i’ve just enabled the “editable children” toggle for the relevant items, but it turns into a mess in the scene overview.
A workaround i want to ditch.

EditorPlugin._forward_canvas_draw_over_viewport() let you draw in the 2D viewport and has a small example on how to use it. You’ll need to also implement EditorPlugin._handles() and EditorPlugin._forward_canvas_gui_input()

Small example:

extends EditorPlugin

func _handles(object: Object) -> bool:
	# Handles only Node2D nodes and nodes that inherit it (so no Controls for example)
	return object is Node2D

func _forward_canvas_draw_over_viewport(viewport_control: Control) -> void:
	viewport_control.draw_circle(viewport_control.get_local_mouse_position(), 64, Color.RED)

func _forward_canvas_gui_input(event: InputEvent) -> bool:
	if event is InputEventMouseMotion:
		return true

	return false

For the other stuff it’s too broad to give any help.

Interesting, interesting.
I’ll give it a go!
i think this will cover most of what i was wondering about.
Not knowing the jargon is part of the problem for me

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.