#resources/values modified in editor via @tool script revert when game is run

1 messages · Page 1 of 1 (latest)

fringe light
#

In the project I'm working on, gameplay areas are represented by 2d "Lanes" the player can move in. I have a tool script that can regenerate the lane after its size or other parameters have changed. When it does this it modifies the size of its CollisionShape2D (the Lane extends Area2D). For example I have a Lane in the world that has a length of 3000 and a rectangular collision shape to match, but when running the game, the size of that very collision shape is back to its default width of 1500.

pic 1 shows the editor where the lane is accurately sized after running its @tool script

pic 2 shows it undersized back to its default in game.

I know I can work around this by running the resizing/regenerating code on _ready or something, but I am worried in the long run about having to do that for every lane (and other level objects that might end up having the same problem), especially when those values are already set in the editor, making it seem redundant to have to rerun those modifying functions.

Is there any way to ensure that those values stay changed?

foggy ruin
#

Are you using the ResourceSaver?

fringe light
foggy ruin
#

Not an addon.

fringe light
foggy ruin
fringe light
fringe light
#

I suppose that isn't exactly true, because those resources are not exposed/editable in the main scene, only in the Lane scene itself.

Is literally saving resources to the file system the only way to get per-instance changes to resources to be persistent? These problems also present themselves whenever I reload the main scene (i.e. switch back to the main scene tab after focusing on another tab)--paths' curves reset to their defaults, collisionshapes reset to their default dimensions, etc.