Is it possible to remove export from native class variable after extending?

Godot Version

4.4

Question

A possible usecase for this would be to be more strict in my project about audio bus usage, to avoid issues of sounds playing on wrong bus.

I would add nodes like these to the project, and enforce using them instead of the base AudioStreamPlayer, but ideally I would also like to remove the “Bus” input in the inspector, to avoid future misunderstandings and headaches

class_name MusicAudioStreamPlayer
extends AudioStreamPlayer

func _init():
	bus = "Music"

class_name VoicesAudioStreamPlayer
extends AudioStreamPlayer

func _init():
	bus = "Voices"

it’s gone!

@tool
class_name MusicAudioStreamPlayer
extends AudioStreamPlayer


func _validate_property(property: Dictionary) -> void:
	if property.name == "bus":
		self[property.name] = &"Music"
		property.usage = PROPERTY_USAGE_NONE

Edit: open and close the scene too for it to work properly

Edit2: you might want to use PROPERTY_USAGE_NO_EDITOR if you’re saving stuff, otherwise you don’t need to

1 Like