0 votes

So I have a button that I want to feed PackedScenes of buildings. I wanna reuse the button and just swap out the PackedScenes for buildings. The buildings would have the icon, name, cost that I want to get into the button. The buildings are .tscn. Is there any other way of doing this? I was thinking of scriptable objects to hold the data for the buildings but I am not familiar with that. I want something that's not resource heavy and without instancing the scene in the button. Can I use preload in the button and then the building will already be loaded for future uses? Is that better for perfomance?

 export (PackedScene) var tscn
 var building_cost 
 var building_name

 func _ready():
 #get the data from the tscn and set it as building name and cost
self.texture_normal = texture

 func _on_BuildingButton_pressed():
Events.emit_signal("building_ButtonPressed", building_cost, building_name)

tried this but they say it isnt fully optimized

in Engine by (39 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.