Skip to content

Working With Resources

By default, a scene’s resources are loaded on-demand. You can manually trigger the loading of all resources in a scene of for specific blocks by calling forceLoadResources. Any set of blocks can be passed as argument and whatever resources these blocks require will be loaded.

In this example, we will show you how to use the CreativeEditor SDK’s CreativeEngine to forcibly pre-load all resources contained in a scene.

forceLoadResources(ids: DesignBlockId[]): Promise<void>

Begins loading the resources of the given blocks and their children. If the resource had been loaded earlier and resulted in an error, it will be reloaded. This function is useful for preloading resources before they are needed. Warning: For elements with a source set, all elements in the source set will be loaded.

  • ids: The blocks whose resources should be loaded. The given blocks don’t require to have resources and can have children blocks (e.g. a scene block or a page block).
  • Returns A Promise that resolves once the resources have finished loading.

Full Code

Here’s the full code:

const scene = engine.scene.get();
// Forcing all resources of all the blocks in a scene or the resources of graphic block to load
await engine.block.forceLoadResources([scene]);
const graphics = engine.block.findByType('graphic');
await engine.block.forceLoadResources(graphics);