hello,
Is there a way to draw a texture in the main editor screen ?

I though this func would work:

func _forward_canvas_draw_over_viewport(overlay):
	# Draw a circle at cursor position.
	#overlay.draw_circle(overlay.get_local_mouse_position(), 164, Color.WHITE)
	
	overlay.draw_texture( img.mouse_tex, overlay.get_local_mouse_position() );

But it seems to be drawing on the GUI, when zooming in and out on the main editor the image remains the same size.
I cant understand the logic ?
"EditorPlugin" doesnt accept func _draw() / @tool extends Sprite2D seems to work,
But what iam suppossed to do ? I already have a node that toggles the plugIN on and off, when the user adds the node to the tree, the plugIN is a *.tscn that handles this node, should i add another node and write the code in there ?

  • xyz replied to this.

    jonSS should i add another node and write the code in there ?

    If you want to avoid nodes you can do it directly via RenderingServer calls

      xyz thanks, this means there is no alternative, i will have to use node... and all script commands i was looking for in renderingServer start with canvas_, looks like a bad idea.

      I was just looking for a better way to do this... the plugIN *.tscn is being added to the right dock, if i add new node the drawing will done there, i guess i could do the drawing in the tileDraw node, but i dont see scripts attached to the other original nodes in godot, something must be wrong... with @tool the image only shows up on the editor.

      • xyz replied to this.

        jonSS Why do you think server calls are bad idea? You communicate directly with the engine that way. Everything nodes do under the hood is calling functions on servers.

          xyz i dont know. It just seemed like it would complicate things even more...
          would this func be the one to draw textures ?

          void canvas_item_add_texture_rect ( RID item, Rect2 rect, RID texture, bool tile=false, Color modulate=Color(1, 1, 1, 1), bool transpose=false )

          void canvas_item_add_texture_rect_region ( RID item, Rect2 rect, RID texture, Rect2 src_rect, Color modulate=Color(1, 1, 1, 1), bool transpose=false, bool clip_uv=true )

          i will give it a try but i dont know what " RID item" is ? or "RID texture"

          • xyz replied to this.

            jonSS RID is a resource identifier. It's a handle to a resource created and maintained by a server.

            You first create resource objects on the server by calling *_create() methods like canvas_item_create() and canvas_texture_create(). Those methods will typically return RIDs. Then you can supply them in calls that expect RIDs. Once you no longer need a resource you have to destroy it by calling free_rid().

            Try to get into habit of reading class reference pages for objects you use. All I've written above is well described in RenderingServer class reference in the official docs.

            So to conclude, you can either do stuff via nodes or by communicating with severs. Go for the latter if you don't want to deal with node system. Servers can do everything the nodes can, and some more.