I made a plugin to make a gizmo for a custom asset I’m developing. Thing is, that asset relies on a Dictionary to set the properties of the gizmo, and when I update the dictionary from the inspector, it does nothing and the changes only apply when I change something else in the scene.
#linegizmo.gd
extends EditorNode3DGizmoPlugin
func _get_gizmo_name():
return "Lines for 3D mapped platforms"
func _has_gizmo(node):
return node is MyClass #custom class
func _redraw(gizmo : EditorNode3DGizmo):
gizmo.clear()
var materials : Dictionary = {}
var meshes = []
var transforms = []
var colors = []
#all arrays are filled in here with data from the dictionary in the editor
for i in range(meshes.size()):
gizmo.add_mesh(meshes[i], materials[colors[i]], transforms[i])
I have a similar problem where I have a custom node type that has properties that I want reflected in my 3D gizmo. When I change these properties in the inspector, _redraw is not called on my 3D gizmo, so it becomes out of date until I switch back and forth between nodes in my scene panel to force a refresh of the gizmo.
My only solution right now is very hacky, so I’d like to hear how others approach this problem.
My hack is to have an autoload tool script that calls _redraw on the last selected gizmo for every _process: