Extending Weird Classes

I'm working on a game engine with swift and metal. I know how to extend a class like this:

class SkySphere: GameObject

But I need a little more than that. I recently updated how objects were loaded into the game engine to support the USDZ file type. This means that meshes are now loaded in as their GameObject. So instead of initializing the GameObject by providing it with a mesh, the mesh returns a GameObject, which I can add to my scene. The problem is that I can't extend these GameObjects to give certain objects (like the SkySphere) their own render functions.

How should I go about extending this class?

Typo: This means that meshes are now loaded in as their GameObject. should be: This means that meshes are now loaded in as their own GameObject

extend a class like this: class SkySphere: GameObject

This is not an extension of GameObject, it is a subclass of GameObject.

If I understand your question (not easy, showing code and explaining what does not work would probably help), you want to write an extension for all classes inherited from GameObject ?

AFAIK, this is not directly possible in Swift, but you may find different ways to do it:

https://stackoverflow.com/questions/54396367/swift-extension-for-all-subclasses-of-a-class

Extending Weird Classes
 
 
Q