How to check if key exists in any/all phaser assets

Hey everyone, I’m adding a way to input custom assets into my game and reference them by key. The user is allowed to input their own custom key to reference the asset.

I need to make sure the custom key they input is unique. Is there any way to get all the keys currently loaded into phaser?

Right now, I am just checking every part where keys are loaded into phaser, but I want to be more rigourous in this check.

    const game = window.game;
    const keyExists =
      !game ||
      game.textures.exists(inputValue) ||
      game.cache.audio.exists(inputValue) ||
      game.anims.exists(inputValue);

There’s no other way, you have to check exists() at each location. The keys need to be unique only per cache or per manager, not per game.

1 Like