+1 vote

I want to change the collisionlayer and collisionmask of all packed scenes in a folder, I managed to accomplish this with the following code:

https://gist.github.com/afk-mario/d1324b6cae73cdc5c3238e1047c2d96b

The issue is that if the scene inherits form a GLTF scene, when I modify and save the packed scene the inheritance is broken.

Godot version v3.4.rc3.official [1a1a45061]
in Engine by (26 points)

I would to know also.

1 Answer

+2 votes
Best answer

I found an answer.
When You instance scene from code, You Have to set GenEditState to GENEDITSTATE_INSTANCE = 1
Be aware that works only from editor. But Your code is "tool" so I suppose it can work.

var scene : PackedScene = load("res://path")
var node : Node = scene.instance(GEN_EDIT_STATE_INSTANCE)
by (94 points)
selected by

Thanks don’t know how I missed that!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.