Skip to content

Commit

Permalink
Add emission line gizmo
Browse files Browse the repository at this point in the history
  • Loading branch information
celyk committed Oct 15, 2024
1 parent 94b133e commit b9e3771
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions gizmo/gizmo.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@tool
extends EditorNode3DGizmoPlugin

var editor_plugin : EditorPlugin

func _init(_editor_plugin:EditorPlugin):
editor_plugin = _editor_plugin
create_material("main", Color(1,1,1), false, true, true)

func _has_gizmo(node):
return node is GPUTrail3D

# show gizmo name in visibility list
func _get_gizmo_name():
return "GPUTrail3DGizmo"

func _redraw(gizmo):
gizmo.clear()

var node3d : Node3D = gizmo.get_node_3d()

var lines = PackedVector3Array()

lines.push_back(Vector3(0,1,0))
lines.push_back(Vector3(0,-1,0))

gizmo.add_lines(lines, get_material("main", gizmo), false, Color(1,1,1,1))
7 changes: 7 additions & 0 deletions plugin.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
@tool
extends EditorPlugin

const MyCustomGizmoPlugin = preload("gizmo/gizmo.gd")
var gizmo_plugin = MyCustomGizmoPlugin.new(self)

func _enter_tree():
# Initialization of the plugin goes here.
# Add the new type with a name, a parent type, a script and an icon.
add_custom_type("GPUTrail3D", "GPUParticles3D", preload("GPUTrail3D.gd"), preload("bounce.svg"))

add_node_3d_gizmo_plugin(gizmo_plugin)

func _exit_tree():
# Clean-up of the plugin goes here.
# Always remember to remove it from the engine when deactivated.
remove_custom_type("GPUTrail3D")

remove_node_3d_gizmo_plugin(gizmo_plugin)

0 comments on commit b9e3771

Please sign in to comment.