Files
GDevelop/GDJS/Runtime/ResourceManager.ts
ViktorVovk 5c71a4da56 Allow to unload scene resources when a scene is exited (#7381)
* This adds two new settings, available in the Project Properties and in the Scene Properties dialog, to allow to specify the strategy for preloading resources of the scenes and unloading them. By default, a game will preload in background the resources of all scenes. It will never unload these resources (so scene switching is fast).
* You can now choose to unload the resources of a scene when the scene is left using the "Resources unloading" field. If the scene is launched again later, it will load its resources again.
* You can also choose to change the preloading to disable it for all scenes (by modifying the setting in the project properties) or enable it/disable it on a scene by scene basis. This can be useful for large or modular games where you anticipate the player to only play some scenes, or if you want to reduce the resources that needs to be loaded on a web game.
2025-07-02 16:09:52 +02:00

50 lines
1.4 KiB
TypeScript

/*
* GDevelop JS Platform
* Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
namespace gdjs {
/**
* A resource managers that download and remember downloaded content for one
* kind of resource.
*/
export interface ResourceManager {
/**
* Load the specified resource.
*
* This method will be run during the game. It should only do light tasks
* like file downloading.
*/
loadResource(resourceName: string): Promise<void>;
/**
* Process the specified resource.
*
* This method will only be run while loading screen is shown. It can do
* heavy tasks like parsing data.
*/
processResource(resourceName: string): Promise<void>;
/**
* Return the kind of resources handled by this manager.
*/
getResourceKinds(): Array<ResourceKind>;
/**
* Should clear all resources, data, loaders stored by this manager.
* Using the manager after calling this method is undefined behavior.
*/
dispose(): void;
/**
* Should clear all specified resources data and anything stored by this manager
* for these resources.
*
* Usually called when scene resoures are unloaded.
*
* @param resourcesList The list of specific resources that need to be clear
*/
unloadResourcesList(resourcesList: ResourceData[]): void;
}
}