Prevent saving a sprite's texture in the scene file?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SteveSmith

I’ve got some pretty massive textures in the sprites in my project and it’s slowing down the Editor. I’ve got a way of loading the textures dynamically from an external location (even in tool mode), but it still saves the loaded texture data with the project. Is there a way to stop it saving a sprite’s texture data?

:bust_in_silhouette: Reply From: aXu_AP

Only way I can think of is not using sprite in saved scene directly, but by instancing sprite from code. As long as you don’t define owner, the node and it’s resources won’t be saved on disk.

If you need to have the sprite in editor to adjust settings etc. you can duplicate the sprite. Something along these lines:

if Engine.editor_hint:
	# Duplicate without scripts, groups or signals
	var duplicate_sprite = target_sprite.duplicate(DUPLICATE_USE_INSTANCING)
	add_child(duplicate_sprite)
	# Set duplicate_sprite.texture
else:
	# Set target_sprite.texture