Skip to main content
added 202 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you get an input on top of the inspector of every asset where you can specify a key for that asset:

Image stolen from https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/unity-addressables-its-never-too-big-to-fit-r5189/

This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. When you need the keys of those assets, then you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key. A code example can be found in the documentation article loading multiple assets, subsection "Correlating loaded assets to their keys".

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you get an input on top of the inspector of every asset where you can specify a key for that asset:

Image stolen from https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/unity-addressables-its-never-too-big-to-fit-r5189/

This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. When you need the keys of those assets, then you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key.

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you get an input on top of the inspector of every asset where you can specify a key for that asset:

Image stolen from https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/unity-addressables-its-never-too-big-to-fit-r5189/

This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. When you need the keys of those assets, then you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key. A code example can be found in the documentation article loading multiple assets, subsection "Correlating loaded assets to their keys".

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.
added 303 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you get an input on top of the inspector of every asset where you can specify a key for eachthat asset.:

Image stolen from https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/unity-addressables-its-never-too-big-to-fit-r5189/

This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. In that caseWhen you need the keys of those assets, then you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key.

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you can specify a key for each asset. This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. In that case you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key.

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you get an input on top of the inspector of every asset where you can specify a key for that asset:

Image stolen from https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/unity-addressables-its-never-too-big-to-fit-r5189/

This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. When you need the keys of those assets, then you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key.

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.
added 168 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you can specify a key for each asset. This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. In that case you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key.

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you can specify a key for each asset. This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime.

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.

When the button is pressed, it saves the skin texture's file name to JSON.

Is the preferred skin a preference of the user? Then did you consider to use PlayerPrefs instead? It provides you with a simple, persistent key-value store.

Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.

This sounds like a perfect use-case for Addressables.

With Addressables, you can specify a key for each asset. This can be the filename, or it can be any other string. You can then load that asset at runtime using that key. Advantages of addressables over Resources is:

  • The assets don't need to be in a folder named Resources. You can make any asset in your project addressable. You can even move those assets around in your project. As long as you don't change the key, the addressable system will still find them.
  • Addressables handle asset bundles in a transparent matter. When you registered asset bundles which contain addressable assets, then you can just use Addressables.LoadAssetAsync and it will automatically figure out which asset bundle contains the asset you want.
  • You can even put asset bundles on the web. The addressable system will then download those asset bundles automatically.
  • You can also tag addressables with Labels. This allows you to mark all your weapon skin textures and then load them all at runtime. In that case you might want to use a two-step process where you first use Addressables.LoadResourceLocationsAsync to get the asset locations and then load each asset with Addressables.LoadAssetAsync(location). The resource locations contain the key of the addressable, so it allows you to associate each addressable with its key.

So tl;dr:

  1. Make the skins addressables. Give each addressable an unique key, and assign the label "weapon_skin" to all of them.
  2. In the menu, load all the addressables with the label "weapon_skin", so you can instantiate a button for each of them.
  3. In the menu, store the key of the chosen skins in PlayerPrefs.
  4. In the game, load the addressable with the key you retrieve from PlayerPrefs.
added 168 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading
added 168 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading
added 146 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading