#"Invalid assignment" in tool script

1 messages · Page 1 of 1 (latest)

full acorn
#

The goal was to have nodes where I could drag a new texture onto an export var and have the visuals update immediately in the editor. No errors while editing, and no errors at runtime, but I do get errors when I first open the scene.

res://UI/PassiveTree/passive_node.gd:13 - Invalid assignment of property or key 'texture_normal' with value of type 'CompressedTexture2D' on a base object of type 'Nil'.

The relevant bits of code, I think, are as follows:

@tool
extends BaseNode
class_name PassiveNode

@onready var button: TextureButton = $Mask/Button

@export var passive_image: Texture :
    set(new_value):
        passive_image = new_value
        if Engine.is_editor_hint():
        button.texture_normal = passive_image

From the bits I've managed to search up online, it might have something to do with the order things are loaded and that setter is firing off before the button is actually ready?

Any ideas how to fix this?

vocal talon
#

I do not think you can use @onready for this.
I think the node cannot be ready in the editor.

Maybe an @export variable could work. But idk if the chosen node also has to be a @tool