Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | squished-01 |
I have about 50 lines of code that I want every UI control in my game to have. What I’d LIKE to do is something like this for a given UI control:
“PlayerNameLineEdit.gd”:
extends LineEdit, "res://Boilerplate.gd"
But
gdscript doesn’t support multiple inheritance. So what I’m currently doing is:
“PlayerNameLineEdit.gd”:
extends "res://LineEditBoilerplate.gd"
“LineEditBoilerplate.gd”
extends LineEdit
But I have to duplicate LineEditBoilerplate.gd for each control type… TextEdit, MenuButton, and change the “extends” line in each. Every time I want to change my boilerplate code, I have to make a change to 10+ nearly identical scripts.
Is there a better way?