Setting @export variable from inspector of scene with @tool shows change visually but not on inspector

Godot Version

4.4.stable

Question

Hello, I have the following setup:

Main (Node3D)
| - Pawn
|…

Pawn (CharacterBody3D)
| - CSGSphere3D
|…

I wanted to change color of the Pawn’s sphere while editing Main scene in editor.

this is pawn.gd

@tool
extends CharacterBody3D

@export var material: Material:
	set(new_material):
		$CSGSphere3D.material = new_material


func _ready() -> void:
	pass

However, when trying to set the Material from editor in Main scene, the color of the Pawn does change but in the inspector the material variable is still set to <empty>.

I have already tried to delete and re-add the Pawn node, reload the scene, restart the engine but it didn’t help.

Sorry for my bad english.

You may need to also assign the value at the end of your setter

@export var material: Material:
	set(new_material):
		$CSGSphere3D.material = new_material
		material = new_material
1 Like

I think this section in the docs can help.

1 Like

Thank you all, I can’t believe I missed something this simple ahah.