GUI.Control.getClassName() only works for Babylon classes

The Babylon GUI method Control.getClassName() only seems to work for Babylon classes. (I.e., it fails to match custom or derived class names.)

Is this by design, since one can use JS constructor.name? (But if so, what is the purpose of Control.getClassName?) Or am I missing something? :slight_smile:

Hey what do you mean by derived class? The getClassName has to be implemented by the dev as we cannot use constructor.name reliably (think about minification for instance)

Yeah, that is basically what I’m talking about! How do we do this reliably? (As far as what I mean by derived classes I’m not sure how to answer that. It’s simply the term used for what it is! LOL. A class derived from another!)

Sorry I mean: if you are creating the derived class, it is up to you to provide the getclassName implementation

…And this is what I’ve done. However, I’m curious why whatever mechanism that is used to store/retrieve the class name of the GUI control doesn’t work for derived classes as well?

We simply override and return a string:
Babylon.js/colorpicker.ts at fc5197908ea7f5c8d54f21ccc35364949d8e387a · BabylonJS/Babylon.js (github.com)

a) What should I be looking at in the code you present? (There is no “getClassName” implementation there.)
b) I didn’t ask how you are doing it; I asked why whatever you are doing doesn’t also work for derived classes.

Sorry I don’t know how to say it differently:

2 Likes

Ah, now I get you! That answers both of my questions, and is the kind of implementation that I was hoping was there. Thanks :slight_smile:

2 Likes