Home Samsung Keep Galaxy Retailer Compatibility for Unity Video games with Play Asset Supply

Keep Galaxy Retailer Compatibility for Unity Video games with Play Asset Supply

0
Keep Galaxy Retailer Compatibility for Unity Video games with Play Asset Supply

Play Asset Supply (PAD) enhances the gaming expertise by providing the benefits of utility bundles, that are packages that group all needed assets for environment friendly supply, making downloads quicker and installations smoother for gamers. Android App Bundles (AAB) are a sort of PAD, the fashionable method of constructing and publishing Android functions and video games in Google Play Retailer. The Samsung Galaxy Retailer not too long ago launched the choice to add AAB information to Galaxy Retailer Vendor Portal. Nevertheless, AABs have some Google Play Retailer proprietary options that may make a sport non-functional when it’s uploaded to Galaxy Retailer. This text explores methods in which you’ll be able to make the most of PAD whereas guaranteeing your sport stays suitable with Galaxy Retailer.

Objective

PAD is a really helpful characteristic that helps cut back the sport’s preliminary obtain dimension, because it downloads numerous sport belongings at runtime. There are a number of methods of utilizing this characteristic in Unity video games. Nevertheless, sure PAD configurations might trigger the sport’s belongings to fail to load when the sport is revealed to Galaxy Retailer. On this tutorial, you learn to correctly configure PAD and alter Unity configurations accordingly, so your sport may be efficiently revealed to Galaxy Retailer.

Within the following sections, PAD functionalities are carried out in an current coin collector sport (referenced within the article Integrating Samsung IAP in Your Unity Recreation), demonstrating the right way to obtain and apply a brand new set of supplies for the ground tile at runtime. Right here, you additionally be taught concerning the changes which can be needed for efficiently publishing a sport utilizing PAD to Galaxy Retailer.

Stipulations

To observe this tutorial, be sure that your setup has the next:

  • Unity Recreation Engine model 2023.2 or above
  • The “Addressables for Android” package deal for Unity
  • A Google Play developer account
  • A Galaxy Retailer Vendor Portal business vendor account
  • A sport created utilizing Unity the place you need to add the PAD options

To implement PAD in your Unity sport, you should utilize the “Addressables for Android” package deal. That is the best and most handy solution to implement PAD in a sport. This package deal is barely supported on Unity model 2023.2 or above. In case your sport is constructed utilizing a earlier model of Unity, please migrate your sport to the Unity 2023.2 model first.

PAD implementation issues

There are multitude of the way to implement PAD in video games constructed with the Unity engine. Nevertheless, the most typical methodology for implementing PAD restricts the sport to being publishable completely on the Google Play Retailer and doesn’t present any simple methodology of disabling PAD for importing these video games into different storefronts. For one of the best expertise along with your sport, it’s endorsed to make use of PAD to bundle all sport belongings collectively. This strategy ensures that each one needed assets are downloaded straight away, stopping any lacking belongings which might have an effect on the consumer expertise.

There are three varieties of asset packs that may be configured whereas utilizing PAD: “Set up Time,” “Quick Observe,” and “On Demand.” Video games that use the “Set up Time” asset packs may be uploaded to Galaxy Retailer with none points as these belongings are put in along with the sport and don’t require any separate downloads. When Galaxy Retailer generates a common APK from AAB information, the “Set up Time” belongings are immediately included within the APK.

Video games which can be designed to solely use “On Demand” or “Quick Observe” asset packs don’t permit downloading their belongings when they’re uploaded to a storefront that’s not the Google Play Retailer. Thus, for any sport that makes use of both the “On Demand” or “Quick Observe” asset pack supply methodology, PAD have to be disabled to be able to add the sport to Galaxy Retailer.

To make sure that your sport’s PAD performance may be simply switched off and your sport is efficiently uploaded to Galaxy Retailer, the “Addressables for Android” package deal have to be used to implement PAD.

This text assumes that you’ve got carried out PAD in your sport utilizing the “Addressables for Android” package deal and that you’ve got additionally configured these two belongings with the next configurations:

  • A “Grass” asset pack set to be downloaded as a “Quick Observe” asset
  • A “Floor” asset pack set to be downloaded as an “On Demand” asset

Within the subsequent sections, you learn to combine PAD into your current Unity sport utilizing the “Addressables for Android” package deal as a way to simply publish your sport to Galaxy Retailer with minimal adjustments.

Primary steps to implement PAD in your Unity sport

On this part, you learn to configure your belongings utilizing PAD performance that retains your sport suitable with each Google Play and Galaxy Retailer.

  1. In Unity, configure “Construct Settings” to run the sport on Android and generate the AAB:
    • Click on File > Construct Settings after which choose the Android tab.
    • On the “Android” tab, choose the Construct App Bundle (Google Play) checkbox.

      Figure 1

      Determine 1: Enabling the “Construct App Bundle” choice

  2. Set up the “Addressables for Android” package deal from the Unity Bundle Supervisor. This moreover installs the “Addressables” package deal as a dependency.
  3. Initialize PAD. Go to Window > Asset Administration > Addressables and click on Init Play Asset Supply.
  4. Figure 2

    Determine 2: “Init Play Asset Supply” choice

  5. Configure the “Addressables Teams” for belongings:
  6. Assign the belongings to the Addressables Group:
  7. Configure the “Play Asset Supply” schema for these addressable teams so as to add the PAD performance to your sport:
  8. Within the “Addressables Teams” dialog field, choose Construct > New Construct > Play Asset Supply.

Now, the sport’s addressable-asset configuration is full. Every asset assigned to an addressable group is packed into an asset pack for that group and the asset pack may be downloaded individually utilizing PAD. Notice that asset packs can solely be downloaded individually from the Play Retailer if their supply sort is “On Demand” or “Quick Observe.”

Loading and utilizing the addressable belongings with AssetReference

This part offers a script which particulars the right way to load the addressable belongings that had been carried out with PAD within the earlier sections. Your sport is about as much as load the addressable belongings effectively. If an asset has not been downloaded but, the sport robotically makes an attempt to obtain it as an “On Demand” asset utilizing PAD earlier than it masses into the sport.

To finish this setup, use the AssetReference sort in your sport. This characteristic lets you handle and edit addressable belongings dynamically at runtime, which provides you extra flexibility and management over the belongings that your sport makes use of.

To make use of two sport addressable belongings in your script, observe these steps:

Within the Unity editor, drag and drop the grass and floor belongings into the fields within the GameObject script part. Now the AssetReferences particularly reference these two belongings throughout runtime.

Downloading belongings throughout runtime is critical for PAD. Use AsyncOperations to load these belongings:

    Grass_mat.LoadAssetAsync<Materials>().Accomplished += OnGrassAssetLoaded;
    Ground_mat.LoadAssetAsync<Materials>().Accomplished += OnGroundAssetLoaded;

The OnGrassAssetLoaded and OnGroundAssetLoaded handler capabilities are outlined to make use of the loaded belongings. The LoadAssetAsync methodology passes the asset utilizing an AsyncOperationHandle, and from there you possibly can entry the asset itself utilizing the AsyncOperationHandle.End result parameter.

On this sport, we’re utilizing PAD to load the grass and floor belongings. As soon as they’re efficiently loaded, you possibly can change the ground tile materials utilizing the next handler capabilities.

On this instance, after loading the grass and floor belongings, you apply the fabric change to all the ground tiles within the stage:

    void OnGroundAssetLoaded(AsyncOperationHandle<Materials> deal with)
    {
        groundMaterial = deal with.End result;

        foreach (GameObject prefab in floorPrefabs)
        {
            prefab.GetComponent<MeshRenderer>().materials = groundMaterial;
        }
    }

Save the script and return to the Unity editor. The brand new supplies are loaded and utilized to the ground tiles within the stage.

Testing your PAD-enabled sport on the Play Retailer and Galaxy Retailer

The sport configuration for utilizing addressable belongings and PAD is full. Earlier than publishing your sport, contemplate whether or not to make use of the “Break up Utility Binary” choice.

  1. On the Android Participant settings, increase “Publishing Settings,” and scroll all the way down to the “Break up Utility Binary” checkbox. This checkbox decides how Unity handles packaging when constructing the sport.
    • If this checkbox is checked, Unity splits the bottom sport information from the asset information when constructing the AAB and lets you configure every PAD characteristic in your sport. Within the photographs beneath, you possibly can see what occurs while you select this feature.
    • If this feature is unchecked, Unity at all times generates a singular archive file and disables PAD. That is the most secure choice for importing your sport to Galaxy Retailer, in case your PAD configuration is utilizing choices that aren’t supported by Galaxy Retailer.
  2. Figure 7

    Determine 7: “Break up Utility Binary” choice

  3. To allow PAD, examine the “Break up Utility Binary” choice
  4. Construct the sport and add the generated AAB file to each the Play Retailer and Galaxy Retailer to examine how the sport behaves in each shops.

If the sport belongings load appropriately in each shops, the PAD configuration was completed appropriately. Beneath is an instance of what may occur if “On Demand” configuration is used as a substitute.

When the sport is downloaded from the Play Retailer, Unity robotically downloads the “On Demand” belongings. A notification for an “Extra file obtain” seems in the course of the obtain course of:

Figure 8

Determine 8: Extra file obtain notification

As soon as the obtain is full, the downloaded asset is loaded in your sport, changing the earlier belongings. On this instance sport case, the outdated floor and grass supplies are modified to the brand new textures configured within the earlier part.

Figure 9

Determine 9: Belongings up to date within the sport

Nevertheless, when the identical sport AAB file is uploaded to Galaxy Retailer and a consumer downloads it from this retailer, the PAD belongings will not be downloaded. Thus, when the sport tries to make use of these belongings, they can’t be loaded into the sport’s reminiscence and glitches may seem.

Whereas further error checking may be completed to keep away from these glitches, the functionalities which require PAD belongings nonetheless can’t be used. Internally, the sport checks the set up supply earlier than attempting to obtain the PAD belongings and throws an error if the sport isn’t put in from the Play Retailer.

Figure 10

Determine 10: Points may happen if a PAD-enabled sport is uploaded to Galaxy Retailer

Making the sport suitable with Galaxy Retailer

To add your sport to Galaxy Retailer, you possibly can alter the asset dealing with to be suitable with Galaxy Retailer. One of the simplest ways to do that is by bundling the belongings along with the bottom sport, as defined within the earlier sections.

This methodology is very beneficial. This ensures that the required belongings are at all times accessible with the sport, in addition to permitting you to vary the belongings throughout runtime, if needed. Although this could enhance the sport obtain dimension and require you to add a separate AAB file to Galaxy Retailer, the method ensures that the belongings are at all times accessible with the sport for full characteristic parity throughout all storefronts.

To make your sport construct suitable with all storefronts, select one of many following approaches.

Choice 1: Uncheck the “Break up Utility Binary” checkbox

Go to Construct Settings > Participant Settings > Publishing Settings and uncheck the Break up Utility Binary checkbox. While you then compile the sport, the brand new AAB file is suitable with Galaxy Retailer and all the sport’s functionalities stay intact.

Figure 11

Determine 11: “Break up Utility Binary” unchecked choice.

With this feature, the belongings are packaged along with the sport and no separate obtain is required.

Choice 2: Change supply sort to “Set up Time”

If you wish to maintain utilizing PAD, you possibly can obtain compatibility by altering all addressable asset teams’ supply sort to “Set up Time.” Remember that when selecting this feature, all belongings must be modified to “Set up Time” one after the other, whereas the earlier one is a one-click course of. In contrast to “On Demand” and “Quick Observe” asset packs, “Set up Time” asset packs are included within the common APK. Thus, the belongings are downloaded along with the sport and work as meant with out inflicting errors.

From the consumer’s perspective, the principle distinction between “Set up Time” and different PAD choices is whether or not the belongings are downloaded when the sport is put in or later throughout gameplay. The preliminary obtain dimension is bigger when the belongings are packaged along with the sport, however then again, the consumer won’t want to attend for the belongings to obtain later throughout gameplay. This allows offline gameplay as effectively.

Conclusion

On this tutorial, you might have realized the right way to configure a Unity sport with PAD in order that it might probably simply be revealed to Galaxy Retailer with out requiring large adjustments or breaking any compatibility. For extra info, try the “Addressables for Android” package deal documentation web page Construct content material for Play Asset Supply. If in case you have any suggestions or questions, attain out to us within the Samsung Builders Discussion board.

LEAVE A REPLY

Please enter your comment!
Please enter your name here