Best way to add an export var

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By navi2000

I have a control that has a bunch of buttons. I need that every button have a variable that I will assign once and never will be changed (an ID). Now I have this implemented by creating a new scene (IdButton) that ineriths from Button and has an exported var:

extends Button

export (int) var id

All my buttons are not from Button type, but IdButton type and they have a new Id variable that I can use in the editor.

There is no really a problem with that, just that I think that it’s not very clean to have a new scene and a new script just to have an exported variable. Is there any better method to implement this?

:bust_in_silhouette: Reply From: chtimy

Hi,

The Object’s instance id is not suitable for what you want?

No, the ID comes from a server so I have to be able to set this ID (cannot use a generated ID)

navi2000 | 2020-04-22 17:51