Hello,

I spent the whole day reading the docs and I cannot figure out how to create an inherited scene from a GDScript.

I'm trying to do that within a post_import script, my goal is to import my Blender file directly as an scene inherited from an existing "character.tscn" packed scene

I have a character.tscn scene that I want all my imported scenes to inherit from. My plan was to add a custom script from the import tab, in which I would, within the post_import() method, I would create an inherited instance of character.tscn, and then add the content of my Blender file as children of that instance.

The PackedScene interface does have an instantiate() method but no apparent way to extend a PackedScene.

According to docs, EditorScenePostImport.post_import() receives scene's root node (not PackedScene).

Could you just instantiate character.tscn in post_import(), add the received root as a child to that instance and return that instance as a new scene root?

Thanks for your reply.

@xyz said: According to docs, EditorScenePostImport.post_import() receives scene's root node (not PackedScene).

I never said it did. The only PackedScene I mentioned is the character.tscn that I would like my returned Node to inherit from.

@xyz said: Could you just instantiate character.tscn in post_import(), add the received root as a child to that instance and return that instance as a new scene root?

This is, in structure at least, what I described. The problem is that I would like a scene inheriting from character.tscn to be returned by my post_import() function, what you describe would, if I understand correctly, create an instance of character.tscn with additional child nodes. The difference being that with the method you described, changes to the original character.tscn wouldn't affect my imported scene.

Have you tried it?

Btw I'm not really sure what you mean by "inherit a scene". AFAIK Scenes do not have inheritance mechanism. They can only be instanced and nested.

Perhaps you should describe in more detail what is your actual goal. What are these scenes needed for? Maybe there is an entirely different approach to achieve it.

a year later