Godot Version
Godot 4.5.1
Question
I ran into a problem while trying to create a very simple plugin that adds a large "Make Unique" button in the Inspector for all Animation Players. The button shows (shown in screenshot at the top), but the functionality doesn't work.
What it’s supposed to do: Make all animations inside this animation player Unique. I also want it to change the icon of the animation player to show that this is a unique one, but I could not figure out how to do that and might end up doing a different type of notifier such as a warning symbol.
This does not happen when I click it, but it does run print() so the button is definitely working. I’ve never made a plugin before, and this seems like a very simple thing that should work. Here is my code. The do_make_unique() function is the main one, and it runs when the button is clicked, proven by the print statement.
@tool
extends EditorInspectorPlugin
func _can_handle(object: Object) → bool:
return object is AnimationPlayer
func _parse_begin(object: Object) → void:
var button: Button = Button.new()
button.text = “Make Unique”
button.pressed.connect(Callable(self,“_do_make_unique”).bind(object))
add_custom_control(button)
func _do_make_unique(AnimPlayer: AnimationPlayer):
print(“Button successfully pressed.”)
var library_names = AnimPlayer.get_animation_library_list()
for lib_name in library_names:
var library: AnimationLibrary = AnimPlayer.get_animation_library(lib_name)
var animation_names = library.get_animation_list()
for name in animation_names:
var animation = library.get_animation(name)
var clone = animation.duplicate_deep(Resource.DEEP_DUPLICATE_ALL)
#Replace the animation with the new one
library.add_animation(name,clone)
#Change icon
#var icon = load("res://Graphics/Textures/Computers/BlueCircle.png")
#AnimPlayer
Any help would be greatly appreciated. Also, if anyone know how to change a node’s icon in real time from this script, that would be greatly appreciated.
