Skip to content

Instantly share code, notes, and snippets.

View viridia's full-sized avatar

Talin viridia

View GitHub Profile
@viridia
viridia / asset-migration.md
Last active January 5, 2025 07:18
Migrating to Bevy Assets V2

Migrating to Bevy Assets V2

Migrating a custom asset loader

Existing asset loaders will need a few small changes to get them to work with Bevy Assets V2.

First, you'll need to add the asset type as an associated type of the loader. This type is called Asset and represents the type of the "default asset" produced by the loader.

You'll also need to add a Settings type which represents options that can be passed to the loader when you request an asset. If your asset has no settings, then you can just set it to the unit type.

@viridia
viridia / SaveGame.ts
Created January 31, 2023 19:17
Example of Structural Sharing for saved games.
export class SavedGameStore<T extends object> {
private prev: { [key: string]: string } = {};
private next: { [key: string]: string } = {};
constructor(private options: ISaveGameOptions = {}) {}
/** Return a list of saved games. */
public list(): ISavedGameRoot[] {
/** Get all the local storage keys that begin with the word 'save'. */
return Object.keys(localStorage)