0 votes

Hi,

I have a tool script attached to an Area2D and I'm trying to draw a line in the editor as a helper.

When I run the game I can see the line being drawn but in the editor it is not appearing.

Here's the code:

tool
extends Area2D

func _ready():
set_physics_process(true)

func _physics_process(delta):
    update()

func _draw():
    draw_line(Vector2(), Vector2(20,50), Color(1,1,1), 3)

I tried both, process and physics_process.

Sorry if this was asked before, I couldn't find the answer.

Any idea?

Thanks

in Engine by (15 points)
edited by

I just tested your codes and works fine for me.
did you restart editor?

damn that was it!! restarted the editor and started working just fine. I feel stupid now.
Thanks a lot

You can also try to close the scene and reopen it

1 Answer

+1 vote
Best answer

You should restart editor once or close and reopen it (as @Zylann said in comment)
You can reload script by File > Soft reload script (Control + Shift + R) for the changes after that.
if it doesn't work well, I suggest to restart editor or reopen it again.

by (9,782 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.