Coder Social home page Coder Social logo

addressables-sample's Introduction

Addressables-Sample

Demo project using Addressables package

These samples are broken up into projects based on high level functionality. These are intended as jumping off points for your own development. These have not been tested, and are not guaranteed to work in your situation. They are just examples, to make some concepts easier to understand, or easier to replicate in your own project. Use at your own risk.

Note: Please report any bugs found through the regular bug submission process https://unity3d.com/unity/qa/bug-reporting. For any questions, create a new thread on the Unity Forums https://forum.unity.com/forums/addressables.156/.

Projects

Basic/Basic AssetReference

Several sample scenes to display functionality surrounding the asset reference class.

  • Scenes/BasicReference
    • Simplest example using a reference to spawn and destroy a game object
    • Each object is instantiated directly via the AssetReference which will increment the ref count.
    • Each object spawned has a script on it that will cause it to release itself after a certain amount of time. This destroys the object and decrements the ref count.
    • Any instances still around when the scene closes will automatically be released (decrementing ref count) by the scene closing process (even if their self-destruct script were disabled).
  • Scenes/ListOfReferences
    • Showcases using references within a list.
    • Key feature: once an AssetReference is loaded it keeps a member called .Asset. In this example, you would not want to use the on-complete callback to save off the asset as the loads may not complete in the same order as they were triggered. Thus, it's useful that the reference keeps up with its own loaded asset.
    • Here the objects are instantiated via the traditional GameObject.Instantiate which will not increment the Addressables ref count. These objects still call into Addressables to release themselves, but since they were not instantiated via Addressables, the release only destroys the object, and does not decrement the ref count.
    • The manager of these AssetReferences must release them in OnDestroy or the ref count will survive the closing of the scene.
  • Scenes/FilteredReferences
    • Showcases utilizing the various filtering options on the AssetReference class.
    • This scene also shows an alternative loading patter to the one used in other scenes. It shows how you can utilize the Asset property. It is recommended that you only use the Asset for ease of load. You could theoretically also use it to poll completion, but you would never find out about errors in that usage.
    • This sample shows loading via the AssetReference but instantiating via Unity's built in method. This will only increment the ref count once (for the load).
    • Currently, the objects created are being destroyed with Addressables.ReleaseInstance even though they were not created that way. As of version 0.8, this will throw a warning, but still delete the asset. In the future, our intent is to make this method not destroy the asset, or print a warning. Instead it will return a boolean so you can destroy manually if needed.
  • Scenes/SubobjectReference
    • Showcases using references with sub objects.
    • An AssetReference contains an main asset (editorAsset) and an optional sub object. Certain reference types (for example, references to sprite sheets and sprite atlases) can use sub objects. If the reference uses a sub object, then it will load the main asset during edit mode and load the sub object during runtime.
    • This scene shows loading a sprite from a sprite sheet (main asset) and loading a sprite as a sub object during runtime.

Basic/Scene Loading

The ins and outs of scene loading.

  • Scenes/Bootstrap
    • This is the scene to start with. From this one you can transition to the other scenes.
    • "Transition to Next Scene" will open a new scene (non-additively), which will close the current scene.
    • "Add Object" will instantiate an addressable prefab into the scene. The point of this button is to show that these items do not need ReleaseInstance called on them. Should you use the Profiler, you will see they get cleaned up on scene close.
  • Scenes/Foundation
    • This is the scene you transition to from Bootstrap.
    • "Load *" buttons will open other scenes additively.
    • "Unload *" buttons will unload scenes that have been additively loaded.
  • Scenes/ItemScenes/*
    • These scenes just contain items with no code. Their purpose is to be additively loaded by the Foundation scene.

Basic/ComponentReference

This example creates an AssetReference that is restricted to having a specific Component.

  • Scenes/SampleScene
    • This scene has a Spawner game object that alternates between spawning a direct reference prefab and an addressable one.
    • Both the direct reference and the addressable ComponentReference can only be set to one of the prefabs with the component ColorChanger on it.
  • Samples/Addressables/1.19.19/ComponentReference/ComponentReference - ComponentReference
    • This is the class that inherits from AssetReference. It is generic and does not specify which Components it might care about. A concrete child of this class is required for serialization to work.
    • At edit-time it validates that the asset set on it is a GameObject with the required Component.
    • At runtime it can load/instantiate the GameObject, then return the desired component. API matches base class (LoadAssetAsync & InstantiateAsync).
  • Scripts/ColorChanger - ColorChanger & ComponentReferenceColorChanger
    • The component type we chose to care about.
    • Note that this file includes a concrete version of the ComponentReference. This is needed because if your game code just specified a ComponentReference it could not serialize or show up in the inspector. This ComponentReferenceColorChanger is what makes serialization and the inspector UI work.
    • Releasing a ComponentReference should be done through ReleaseInstance() in the ComponentReference class. To release an instance directly, see our implementation of ReleaseInstance to understand the requirements.

Basic/Sprite Land

2019.3.0a11+ - Sprite demo is back. There was an engine bug causing a crash when loading out of sprite sheets that caused us to remove this demo. This is in 2019.3 alpha, and is being backported to 2019.2 and 2018.4. If you use this demo, and your game crashes, or you get warnings about "gfx" not on main thread, you don't have a fixed version of the platform. There are three sprite access methods currently demo'd in this sample. The on-screen button will change functionality with each click, so you can demo the methods in order.

  • Scenes/SampleScene
    • First is having an AssetReference directly to a single sprite. Since this sprite is a single entry, we can reference the asset directly and get the sprite. This is the most simple case.
    • Second is accessing a sprite from within a sprite sheet. This is the one that was causing a crash, but should be fixed now. Here we load the sprite sheet asset as type IList. This tells addressables to load all the sub-objects that are sprites, and return them as a list.
    • Third is accessing a sprite from within an atlas. In this case, you have to use addressables to load the sprite atlas, then use the normal atlas API to load a given sprite from it. This example also shows extending the AssetReference to provide a typed reference that Addressables doesn't come with (AssetReferenceT in this case).
  • All code is in Scripts/SpriteControlTest.cs

Basic/Space Shooter (Legacy)

Referenced in past Unite video(s):

A very simple Unity tutorial that we converted to use addressables. The main code file to look at would be Done_GameController.cs, but in general, this is just meant as a simple project to explore.

Advanced/Addressables Variants (Legacy)

Referenced in past Unite video(s):

An example project to show two use cases or workflows for creating "variants". The new build pipeline (Scriptable Build Pipeline) upon which Addressables is built, does not support asset bundle variants. This old mechanism was useful in many instances, so this sample is meant to show how to accomplish similar results for one of those instances.

  • Scenes/TextureScalerScene
    • In the scene, there's a prefab with an existing texture that can load alternate textures based on button input. (VariationController.cs)
    • The project only has one instance of the texture in question (Texture/tree2.png). It is marked as addressable, with the address "tree" and no labels
    • The group containing "tree" has a custom schema added to it (TextureVariationSchema). This defines the label for the provided texture, and a scale and label for alternate textures.
    • For "Use Asset Database (fastest)" in the player, run with the play mode script of "Variant Use Asset Database (fastest)". This will look at all the label variations defined in the schema, and apply all labels to the "tree". This will then go into play mode in the normal "Use Asset Database (fastest)" setup of loading from AssetDatabase, but will fake having an "HD", "SD", etc. version of the texture.
    • For "Simulate Groups (Advanced)" in the player, run with the play mode script of "Variant Simulate Groups (Advanced)". This will do the same things as the "Variant Use Asset Database (fastest)" script above. Note, this is not a very accurate "Simulate Groups (Advanced)" mode right now because it does not emulate the fact that each variety should be in its own bundle.
    • With the build script of "Pack Variations" selected, building the player content will:
      • Find all groups with the TextureVariationSchema
      • Loop over all size/label pairs, and copy the textures on-disk.
      • Change the import settings on the created textures so as to scale them.
      • Build all bundles
      • Remove the extra files/groups that were created.
    • After building with "Pack Variations", you can enter play mode using the standard "Use Existing Build (requires built groups)" script.
  • Scenes/PrefabTextureScalerScene
    • In this scene an Addressable prefab that gets duplicated with variant textures.
    • The project only has one instance of the prefab (Assets/Cube.prefab). This prefab has a Material that references a texture in the project.
    • The group containing the prefab has a custom schema attached to it (PrefabTextureVariantSchema.cs). This schema defines the label for the default prefab as well as labels and texture scales for the variant prefabs and their textures. PrefabTextureVariantSchema will only iterate over GameObjects that have a MeshRenderer with a valid material and texture assigned to it.
    • For "Use Asset Database (fastest)" in the player, run with the play mode script of "Variant Use Asset Database (fastest)". This will look at all the label variations defined in the schema, and apply all labels to the "Prefab". This will then go into play mode in the normal "Use Asset Database (fastest)" setup of loading from AssetDatabase, but will fake having an "LowRes", "MediumRes", etc. version of the prefab.
    • For "Simulate Groups (Advanced)" in the player, run with the play mode script of "Variant Simulate Groups (Advanced)". This will do the same things as the "Variant Use Asset Database (fastest)" script above. Note, this is not a very accurate "Simulate Groups (Advanced)" mode right now because it does not emulate the fact that each variety should be in its own bundle.
    • With the build script of "Pack Variations" selected, building the player content will:
      • Find all groups with the PrefabTextureVariantSchema.
      • Iterate through the group and duplicate any GameObjects into an "AddressablesGenerated" folder on-disk and mark the duplicates as Addressables.
      • Check if the asset hash for an entry has changed and only create new variants whose source has a new asset hash.
      • Iterate through each label/scale pair and create on-disk copies of the materials and textures for each of those GameObjects.
      • Change the import settings on the created textures so as to scale them accordingly.
      • Build the AssetBundles.
      • Remove the extra groups that were created.
      • Removed unused variant assets.
    • After building with "Pack Variations", you can enter play mode using the standard "Use Existing Build (requires built groups)" script.

Advanced/Custom Analyze Rule

This sample shows how to create custom AnalyzeRules for use within the Analyze window. Both rules follow the recommended pattern for adding themselves to the UI. There are no scenes to look at in this project, just analyze code.

  • Samples/Addressables/1.20.0/Custom Analyze Rules/Editor/AddressHasC
    • This is a non-fixable rule (meaning it will not fix itself).
    • When run, it checks that all addresses have a capital C in them. Any that do not are flagged as errors.
    • A rule like this would be useful if your studio enforced some sort of naming convention on addresses. (though it would probably be best if it could fix itself)
  • Samples/Addressables/1.20.0/Custom Analyze Rules/Editor/CheckBundleDupeDependenciesMultiIsolatedGroups
    • This is a fixable rule. It is similar to the "Check Duplicate Bundle Dependencies" as fixing the rule will resolve duplicate bundle dependencies. However in this case duplicates will be moved to multiple isolation groups. Duplicates referenced by the same groups will be moved to the same isolation group.
    • In the sample project there are 3 groups provided to illustrate this behavior:
      • The Ground Materials Group contains a ScriptableObject that references the materials DirtMat and GrassMat.
      • The Water Materials Group contains a ScriptableObject that references the material WaterMat.
      • The All Materials Group contains a ScriptableObject that references all 3 materials DirtMat, GrassMat, and WaterMat. It shares the same bundle dependencies as the Ground and Water Materials Group.
    • Fixing the "Check Duplicate Bundle Dependencies Multi-Isolated Groups" rule will create 2 new isolation groups:
      • The first Duplicate Asset Isolation group contains the materials DirtMat and GrassMat.
      • The second Duplicate Asset Isolation groups contains the material WaterMat.
  • Samples/Addressables/1.20.0/Custom Analyze Rules/Editor/PathAddressIsPath
    • This is a fixable rule. Running fix on it will change addresses to comply with the rule.
    • When run, it first identifies all addresses that seem to be paths. Of those, it makes sure that the address actually matches the path of the asset.
    • This would be useful if you primarily left the addresses of your assets as the path (which is the default when marking an asset addressable). If the asset is moved within the project, then the address no longer maps to where it is. This rule could fix that.

Advanced/Play Asset Delivery

An example project that shows how to use Unity's Play Asset Delivery API with Addressables. SampleScene (located in 'Assets/Scenes') contains 3 buttons that will load or unload an asset assigned to a specific delivery type.

Note: Play Asset Delivery requires Unity 2019.4+. This project uses Unity 2020.3.15f2.

Use this project as a guide to make custom asset packs. If you don't want to use custom asset packs, follow the instructions in Play Asset Delivery to use the Play Asset Delivery API with the default Addressables configuration.

You can use the default Addressables configuration in this case because the AddressablesPlayerBuildProcessor moves all content located in Addressables.BuildPath to the streaming assets path. Unity assigns streaming assets to the generated asset packs.

Basic Workflow
  1. Assign an Addressable Group to an asset pack. You can assign multiple groups to the same asset pack. If you do this, you should be aware of the size restrictions that each delivery mode has. For more information, see Android's Play Asset Delivery documentation.
    • By default, Addressables includes the content of any groups that use Addressables.BuildPath in the streaming asset path.
    • For additional custom asset packs, you must create an “{asset pack name}.androidpack” directory in the Assets folder for each asset pack. Optionally add a .gradle file to this directory to specify the asset pack's delivery type. The default type is "on-demand" delivery. For more information, see the example in the BuildScriptPlayerAssetDelivery.cs file in this project.
  2. To assign an AssetBundle to an asset pack, move the .bundle file to the “{asset pack name}.androidpack” directory (see PlayAssetDeliveryBuildProcessor.cs). We also maintain a system that keeps track of all our custom asset pack names which bundles are assigned to them (see BuildScriptPlayerAssetDelivery.cs and PlayAssetDeliveryInitialization.cs).
  3. Build the Android App Bundle and upload it to the Google Play Console to generate the APK.
  4. At runtime, download asset packs before loading bundles from them (see PlayAssetDeliveryAssetBundleProvider.cs).
Configure Build & Player Settings

Configure Unity to build Android App Bundles. For more information see "Play Asset Delivery".

  1. Go to File > Build Settings and set the Platform property to Android. If Export Project is enabled, enable Export for App Bundle. Otherwise, enable Build App Bundle (Google Play).
  2. If you want any bundled content to use "install-time" delivery, enable Split Application Binary in Edit > Project Settings > Player > Publishing Settings.
Configure custom Addressables scripts

The sample project uses custom Addressables scripts that make it easier to build and load AssetBundles assigned to asset packs.

  • The 'Assets/PlayAssetDelivery/Data' directory contains the following files:
    • A custom group template (Asset Pack Content.asset).
    • A custom data builder asset (BuildScriptPlayAssetDelivery.asset).
    • A custom initialization object (PlayAssetDeliveryInitializationSettings.asset)
  • The 'Assets/PlayAssetDelivery/Editor' directory contains the following files:
    • A custom data builder script (BuildScriptPlayAssetDelivery.cs).
    • A custom build processor (PlayAssetDeliveryBuildProcessor.cs)
    • A custom schema (PlayAssetDeliverySchema.cs)
  • The 'Assets/PlayAssetDelivery/Runtime' directory contains the following file:
    • A custom AssetBundle Provider (PlayAssetDeliveryAssetBundleProvider.cs)
    • A custom initializable object (PlayAssetDeliveryInitialization.cs)

Addressables imports most of the scripts automatically, but you need to manually configure some assets in the AddressableAssetSettings:

  1. In the Build and Play Mode Scripts list add the custom data builder asset (BuildScriptPlayAssetDelivery.asset).
  2. In the Asset Group Templates list add the custom group template (Asset Pack Content.asset).
  3. In the Initialization Objects list add the custom initialization object (PlayAssetDeliveryInitializationSettings.asset).
Assign Addressables Groups to asset packs
  1. Go to the Addressables Groups window (Window > Asset Management > Addressables Groups) toolbar and select Create > Group > Asset Pack Content to create a new group whose content will be assigned to an asset pack. The group contains 2 schemas Content Packing & Loading and Play Asset Delivery.
  2. Specify the assigned asset pack in Play Asset Delivery schema. Select Manage Asset Packs to modify custom asset packs.
    • Assign all content intended for "install-time" delivery to the "InstallTimeContent" asset pack. This is a "placeholder" asset pack that is representative of the generated asset packs. No custom asset pack named "InstallTimeContent" is actually created.
    • In most cases the generated asset packs will use "install-time" delivery, but in large projects it may use "fast-follow" delivery instead. For more information see "Generated Asset Packs".
    • Note: To exclude the group from the asset pack either disable Include In Asset Pack or remove the Play Asset Delivery schema. Additionally make sure that its Content Packing & Loading > Build Path property does not use the Addressables.BuildPath or Application.streamingAssetsPath. Any content in those directories will be assigned to the generated asset packs.
  3. In the Content Packing & Loading schema:
    • Set the Build & Load Paths to the default local paths (LocalBuildPath and LocalLoadPath). At runtime, configure the load paths to use asset pack locations. For an example of how to do this, see the PlayAssetDeliveryInitialization.cs file.
    • Note: Since the Google Play Console doesn't provide remote URLs for uploaded content, it is not possible to use remote paths or the Content Update workflow for content assigned to asset packs. Remote content will need to be hosted on a different CDN.
    • In Advanced Options > Asset Bundle Provider use the Play Asset Delivery Provider. This will download asset packs before loading bundles from them.
Build Addressables

Build Addressables using the custom "Play Asset Delivery" build script. In the Addressables Groups Window, do Build > New Build > Play Asset Delivery. This script will:

  1. Create the config files necessary for creating custom asset packs
    • Each asset pack will have a directory named “{asset pack name}.androidpack” in the 'Assets/PlayAssetDelivery/Build/CustomAssetPackContent' directory.
    • Note: All .bundle files created from a previous build will be deleted from the 'Assets/PlayAssetDelivery/Build/CustomAssetPackContent' directory.
    • Each .androidpack directory also contains a ‘build.gradle’ file. If this file is missing, Unity will assume that the asset pack uses "on-demand" delivery.
  2. Generate files that store build and runtime data that are located in the 'Assets/PlayAssetDelivery/Build' directory:
    • Create a 'BuildProcessorData.json' file to store the build paths and .androidpack paths for bundles that should be assigned to custom asset packs. At build time this will be used by the PlayAssetDeliveryBuildProcessor to relocate bundles to their corresponding .androidpack directories.
    • Create a 'CustomAssetPacksData.json' file to store custom asset pack information to be used at runtime.
Create Runtime Scripts that configure custom Addressables properties

Prepare Addressables to load content from asset packs at runtime (see PlayAssetDeliveryInitialization.cs):

  1. Make sure that the generated asset packs are downloaded.
  2. Configure the custom InternalIdTransformFunc, which converts internal ids to their respective asset pack location.
  3. Load all custom asset pack data from the "CustomAssetPacksData.json" file.

Once configured, you can load assets using the Addressables API (see LoadObject.cs).

Note: To load content from AssetBundles during Play Mode, go to the Addressables Groups window (Window > Asset Management > Addressables Groups) toolbar and select Play Mode Script > Use Existing Build (requires built groups).

Build the Android App Bundle

When you have configured the build settings according to the Configure Build & Player Settings instructions, go to File > Build Settings and select Build to build the Android App bundle.

Note: You can't upload a development build to the Google Play Console. If you want to upload your App Bundle to the Google Play Console, ensure that you create a release build. For more information, see Build Settings.

The PlayAssetDeliveryBuildProcessor will automatically move bundles to their "{asset pack name}.androidpack” directories in 'Assets/PlayAssetDelivery/Build/CustomAssetPackContent', so that they will be assigned to their corresponding custom asset pack. Then Unity will build all of the custom asset packs along with the generated asset packs.

addressables-sample's People

Contributors

alffanclub avatar andymunity avatar kirstenpilla avatar luchianno avatar obsessivenerd avatar unitydavid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

addressables-sample's Issues

How do I get the scene name?

There is a sign near my transfer platform. It indicates the target of this transport platform.
If I load the scene, it's easy to get the name. But I don't want to load the scene.
All scene files are filled in the edit window. I should be able to get the file name, but I didn't find the corresponding API.

Having trouble deleting an InstantiateAsync object

Hi,

I have an AR App where when an Image gets detected, it should Instantiate an AssetReference that image is associated with.

But I have another method where if a new Image is detected, I want to first delete the previously instantiated AssetReference, and then instantiate the AssetReference associated with the new Image.

Here is my code:

`
public class MultiTrackedImageManager : MonoBehaviour
{

public static MultiTrackedImageManager Instance { get { return instance; } }
private static MultiTrackedImageManager instance;

private ARTrackedImageManager m_TrackedImageManager;
private GameObject curobject;
private string PREFABFOLDER = "Prefabs/";

AssetBundle myLoadedAssetBundle;
[SerializeField]
private string imageName;
private GameObject prefabToLoad;

public List<MultiTrackedImage> Images = new List<MultiTrackedImage>();

// Addressables necessities for test
GameObject target;
private Vector3 spawnPosition;
GameObject testObj;

private void Awake()
{
    //if (instance != null) { Destroy(instance); }
    instance = this;
    m_TrackedImageManager = GetComponent<ARTrackedImageManager>();
    curobject = null;
    spawnPosition = Vector3.zero;
}
void OnEnable()
{
    m_TrackedImageManager.trackedImagesChanged += OnTrackedImagesChanged;
}

void OnDisable()
{
    m_TrackedImageManager.trackedImagesChanged -= OnTrackedImagesChanged;
}

void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs eventArgs)
{

    foreach (var trackedImage in eventArgs.updated)
    {
        OnImageUpdated(trackedImage.referenceImage.texture.name, trackedImage.name, trackedImage);
    }

    foreach (var trackedImage in eventArgs.added)
    {
        OnImageAdded(trackedImage.referenceImage.texture.name, trackedImage.name, trackedImage);
    }
}

public void OnImageUpdated(string textureName, string name, ARTrackedImage m_ARTrackedImage)
{
    
    for (int i = 0; i < Images.Count; i++)
    {
        //if we have a match for the object and we have regained tracking and the current object is not the one for the trigger we just found
        if (m_ARTrackedImage.trackingState == TrackingState.Tracking)
        {

            //this checks to make sure we are tracking the right image target
            if(!string.Equals(Images[i].target.name, textureName)) { continue; }

            //this checks to see if our current object is equal to the name of the image target so we don't delete and duplicate
            if (string.Equals(curobject.name, Images[i].target.name)) { continue; }

            //for some reason we are getting updates from non visible targets
            if (curobject != null) { Destroy(curobject);}

            GameObject go = GameObject.Find(name);

            //Instantiate the prefab with the position of go
            var addresableTarget = Addressables.InstantiateAsync(Images[i]._prefabReference, go.transform.position, Quaternion.identity);

            if(target != null) {Addressables.Release(target); Addressables.ReleaseInstance(addresableTarget); }
            target = addresableTarget.Result;

            curobject = target;
            curobject.name = Images[i].target.name;

            TextManager.s.txtContent1 = Images[i].txt1 == "" ? "  " : Images[i].txt1;
            TextManager.s.txtContent2 = Images[i].txt2 == "" ? "  " : Images[i].txt2;
            TextManager.s.ResetText();

            Images[i].go = go;
            target.transform.rotation = go.transform.rotation;
            target.transform.SetParent(go.transform);
            target.transform.localPosition = Vector3.zero;
        }
    }
}

public void OnImageAdded(string textureName, string name, ARTrackedImage m_ARTrackedImage)
{

    //PrefabManager.s.ClearPrefabs();
    for (int i = 0; i < Images.Count; i++)
    {
        if (string.Equals(Images[i].target.name, textureName) && Images[i].go == null)
        {
            //Destroy the existing AR Animation
            if (curobject != null) { Destroy(curobject);}

            GameObject go = GameObject.Find(name);

            //Instantiate the prefab with the position of go
            var addresableTarget = Addressables.InstantiateAsync(Images[i]._prefabReference, 
go.transform.position, Quaternion.identity);

            if (target != null) { Addressables.Release(target); Addressables.ReleaseInstance(addresableTarget); }
            target = addresableTarget.Result;

            curobject = target;
            curobject.name = Images[i].target.name;

            TextManager.s.txtContent1 = Images[i].txt1 == "" ? "  " : Images[i].txt1;
            TextManager.s.txtContent2 = Images[i].txt2 == "" ? "  " : Images[i].txt2;
            TextManager.s.ResetText();

            Images[i].go = go;
            target.transform.rotation = go.transform.rotation;
            target.transform.SetParent(go.transform);
            target.transform.localPosition = Vector3.zero;
        }
    }
}

`

Play Asset Delivery Integration Attempting to use an invalid operation handle error.

Hi!

I am using Addressables Package "1.19.17" to create asset bundles on "Unity 2020.3.27f1" and I am getting this error:

Exception: Attempting to use an invalid operation handle

Call Stack:
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1[TObject].get_InternalOp () (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1[TObject].get_Result () (at <00000000000000000000000000000000>:0) UnityEngine.AddressableAssets.Initialization.InitializationOperation.Execute () (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeExecute () (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1+<>c__DisplayClass58_0[TObject].<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1[TObject] s) (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) DelegateList1[T].Invoke (T res) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeCompletionEvent () (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.Exception exception, System.Boolean releaseDependenciesOnFailure) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg, System.Boolean releaseDependenciesOnFailure) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.InitalizationObjectsOperation.b__8_0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1[TObject] obj) (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) DelegateList1[T].Invoke (T res) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeCompletionEvent () (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.Exception exception, System.Boolean releaseDependenciesOnFailure) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.GroupOperation.CompleteIfDependenciesComplete () (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1+<>c__DisplayClass58_0[TObject].<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1[TObject] s) (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) DelegateList1[T].Invoke (T res) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeCompletionEvent () (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.Exception exception, System.Boolean releaseDependenciesOnFailure) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg, System.Boolean releaseDependenciesOnFailure) (at <00000000000000000000000000000000>:0) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) (at <00000000000000000000000000000000>:0) AddressablesPlayAssetDelivery.PlayAssetDeliveryInitializeOperation.CompleteOverride (System.String warningMsg) (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <00000000000000000000000000000000>:0) UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0) UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0) DelegateList1:Invoke(T) System.Action1:Invoke(T) DelegateList1:Invoke(T) System.Action1:Invoke(T) DelegateList1:Invoke(T) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:Complete(TObject, Boolean, String) AddressablesPlayAssetDelivery.PlayAssetDeliveryInitializeOperation:CompleteOverride(String) UnityEngine._AndroidJNIHelper:InvokeJavaProxyMethod(AndroidJavaProxy, IntPtr, IntPtr)

PAD sample does not build

The current PAD sample does not build an aab correctly.

Repro steps;
-Build addressables with the PAD script
-Try to build an .aab

The gradle build will fail with main/src/assets not found exception for both custom packs - fast-follow and on-demand.

Changing the build script to put bundles into *.assetpack/src/main/assets makes it build, and the builds "work" when buildintg them using bundletoot with --local-testing, but the assets aren't pulled correctly when the build is downloaded from google play.

Sample presents glitches in Android in "Use Existing Build" play mode script mode

Hi,
I'm basically experiencing the issue explained here. The thing is, while I understand that there are shaders that can only be rendered in specific platforms, shouldn't the sample work right away without these visual glitches? The exact same project works just fine when the platform is iOS.

I sadly lost a couple of days trying to figure out why it looked like my project wasn't properly loading some random textures until I tested the sample project only to find out that the same issue happened there.

I'd appreciate any explanation to try to avoid this issue in the future.
Many thanks,

Unity 2019.4.10 Addressables 1.15.1 SyncAddressale Demo

It is seem to be wrong with above unity versions.
Exception: Sync Instantiate failed to finish! Cube SyncAddressables.Instantiate (System.Object key, UnityEngine.Transform parent, System.Boolean instantiateInWorldSpace) (at Assets/SyncAddressables/SyncAddressables.cs:57) spawner.FixedUpdate () (at Assets/spawner.cs:34)

Custom asset packs are not generated

"Build Addressables content on Player Build" setting does not generate custom asset packs.

<Good example>

  1. "Do not Build Addressables content on Player Build"
  2. Build > New Build > Play Asset Delivery
  3. build the apk

There are three asset packs: CustomFastFollow, CustomOnDemand, and UnityDataAssetPack.

<Bad example>

  1. "Build Addressables content on Player Build"
  2. build the apk

BuildScriptPlayAssetDelivery.DoBuild is executed.
But, there is only UnityDataAssetPack.

dependencies in texture variations examlpe

The package contains dependencies from another project.

    "com.unity.addressables": "file:../../../AddressablesDemo_cds/AddressablesDemo/Packages/com.unity.addressables",
    "com.unity.scriptablebuildpipeline": "file:../../../AddressablesDemo_cds/AddressablesDemo/Packages/com.unity.scriptablebuildpipeline",
    "com.unity.scriptablebuildpipeline.experimental": "file:../../../AddressablesDemo_cds/AddressablesDemo/Packages/com.unity.scriptablebuildpipeline.experimental",

Addressables are not working on WebGL on new Unity versions

Hi,

as said in the title, addressables are not working on WebGL. Tested on 2 examples from this repository: Scene Loading and Sprite Land. They work on their original version (2019.4.9f1) and on 2020.3.33f. When I bump the version to 2022.1.23f1 I'm getting the errors listed below:

Asset Bundle download is complete, but no data have been received

RemoteProviderException : Unable to load asset bundle from : [http://localhost:8000/StreamingAsse...s_all_f4ba373f651003dcc29897ae4302b413.bundle](http://localhost:8000/StreamingAssets/aa/WebGL/defaultlocalgroup_assets_all_f4ba373f651003dcc29897ae4302b413.bundle) UnityWebRequest result : ConnectionError : Received no data in response ResponseCode : 200, Method : GET url : [http://localhost:8000/StreamingAsse...s_all_f4ba373f651003dcc29897ae4302b413.bundle](http://localhost:8000/StreamingAssets/aa/WebGL/defaultlocalgroup_assets_all_f4ba373f651003dcc29897ae4302b413.bundle)

I've checked on versions:

  • 2022.1.23f1
  • 2022.2.0b15
  • 2023.1.0a19

Reproduction steps:

  1. Get example code from this repository
  2. Open Scene Loading or Sprite Land
  3. Bump the unity version to one of the listed above
  4. Fix any errors that occurred because of version change
  5. See the errors
  6. Lower the version to 2020.3.33f
  7. See no errors

Missing Examples HTTP build/load setup.

Hi, I followed
https://docs.unity3d.com/Packages/[email protected]/manual/AddressableAssetsHostingServices.html
to the word. But I'm unable to get this working with a server running on the local machine.
Exception encountered in operation Resource(editorhostedpacks_assets_all_3fc51f1662e9e7ea337ef78d2a947322.bundle): RemoteAssetBundleProvider unable to load from url http://162.17.216.37:62868/editorhostedpacks_assets_all_3fc51f1662e9e7ea337ef78d2a947322.bundle, result='Cannot connect to destination host'.

Please add an example for HTTP setup.

Addressables AssetReference "None" value is not saved in Editor when used in Prefab

  1. There is a public field of Addressables.AssetReference type in MonoBehaviour component.
    This component is attached to a GameObject that is converted into prefab. Then prefab instance is added to the Scene. Changing field value to anything except "None" (empty) works fine. But after the value has been changed to anything it can not be changed back to "None" (empty value).
    Changing value inside of the Prefab to anything except "None" partially solves the problem, but that's not a solution because it forces the prefab to keep reference to some object.
  2. Steps to reproduce:
    2.1. Open project attached.
    2.2. Open the SampleScene and select ObjectWithReference instance on the Scene.
    2.3. In Inspector change value of field "Asset Reference" to "None".
    2.4. Save the Scene.
    2.5. Reload the Scene.
    2.6. Select ObjectWithReference instance on the Scene.
    2.7. Result: the value is not "None" but the reference to the object that was set before.
    Expected result: the value is set to "None".

Not all references are being released

var comp = arg.Result.GetComponent<TComponent>();

AsyncOperationHandle<TComponent> GameObjectReady(AsyncOperationHandle<GameObject> arg)
{
        var comp = arg.Result.GetComponent<TComponent>();
        return Addressables.ResourceManager.CreateCompletedOperation<TComponent>(comp, string.Empty);
}

Using the AssetReferenceComponent i see some references to things i have released still sticking around.
Adding this extra release here seems to allow things to load and the other references i was seeing are going away now.

AsyncOperationHandle<TComponent> GameObjectReady(AsyncOperationHandle<GameObject> arg)
    {
        var comp = arg.Result.GetComponent<TComponent>();
        Addressables.Release(arg);
        return Addressables.ResourceManager.CreateCompletedOperation<TComponent>(comp, string.Empty);
    }

Is this a correct fix?

How to manage AddressableGroups by script

With a great amout of assets, I want to manage assets by script instead of creating groups and drag the assets inside by hand.
Please tell me some examples or how to do it.
Thanks

Error when using Addressables and AWS Mobile SDK for Unity

Forum entry: https://forum.unity.com/threads/error-when-using-addressables-and-aws-mobile-sdk-for-unity.697352/

Reproduce:

  1. Get AWS Mobile SDK from https://docs.aws.amazon.com/de_de/mobile/sdkforunity/developerguide/what-is-unity-plugin.html (Download ZIP file and Unzip this).
  2. Load any unity package from the unzipped ZIP file into Unity 2018.4 or higher, importing everything.
  3. Then install "Addressables" from the Package Manager. This results in an error, see screenshot (Error.jpg).

Info:
I "fixed" it by commenting out line 464 from the "Client.cs" script from the "Scriptable Build Pipeline" package (see Fix.jpg). The "Scriptable Build Pipeline" package is installed automatically when you install the "Addressables" package from the Package Manager.

Could you replace "InvalidDataException()" with something else? :)
Error
Fix

UnloadScene exeption, not unloading

Unity 2019.1.1f1
Adressables 0.7.5

To reproduce. try add scene example.

https://github.com/Unity-Technologies/Addressables-Sample/blob/master/Basic/Scene%20Loading/Assets/AddScenes.cs

Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[UnityEngine.ResourceManagement.ResourceProviders.SceneInstance], result='', status='Failed': Addressables.UnloadScene() - Cannot find handle for scene UnityEngine.ResourceManagement.ResourceProviders.SceneInstance
UnityEngine.AddressableAssets.Addressables:UnloadScene(SceneInstance, Boolean)

https://github.com/Unity-Technologies/Addressables-Sample/blob/master/Basic/Scene%20Loading/Assets/AddScenes.cs

Nothing in FilteredRefenrence

Hello, I see nothing special in scene FilteredReference.
Is this repo up to date ?
I guess FilteredReference allows to list addressable assets in the drop down list with some criteria like labels ?
Thanks for your great work addressable sounds to be a great feature !

Readability issues

Hello, few ux/readability issues (see screenshot below)

  • the labels popup menu is not properly adjusting its size
  • the selected row highlight is not setup for pro skin

image

Play Asset Delivery sample does not properly load from fast-follow Asset Pack

In the build (with Google AAB enabled and Split Binary Enabled) I get this error:

2022/07/21 02:46:24.286 18827 18893 Error Unity Unable to open archive file: jar:file:///data/app/~~gxXApkMk8ruxFu9eaUAgMQ==/com.squadbuilt.af-uz7s-6oSaqWPZBUrYokMNQ==/split_UnityDataAssetPack.apk!/assets/aa/map_assets_all_a7a80834016864ae22e9f95f6478a5c2.bundle

This is what entries in BuildProcessData.json look like

{"BundleBuildPath":"Library/com.unity.addressables/aa/Android/map_assets_all_a7a80834016864ae22e9f95f6478a5c2.bundle","AssetsSubfolderPath":"AFSFastFollow.androidpack\map_assets_all_a7a80834016864ae22e9f95f6478a5c2.bundle"}

This is what the entries in CustomAssetPacksData.json look like

{"Entries":[{"AssetPackName":"AFSFastFollow","DeliveryType":2,"AssetBundles":["map_assets_all_a7a80834016864ae22e9f95f6478a5c2"]}]}

This is what AppBundleTransformFunc returns as location.InternalId

jar:file:///data/app/~~gxXApkMk8ruxFu9eaUAgMQ==/com.squadbuilt.af-uz7s-6oSaqWPZBUrYokMNQ==/split_UnityDataAssetPack.apk!/assets/aa/map_assets_all_a7a80834016864ae22e9f95f6478a5c2.bundle

Stack Trace:
2022/07/21 02:46:24.281 18827 18869 Info Unity AppBundleTransformFunc (jar:file:///data/app/~~gxXApkMk8ruxFu9eaUAgMQ==/com.squadbuilt.af-uz7s-6oSaqWPZBUrYokMNQ==/split_UnityDataAssetPack.apk!/assets/aa/map_assets_all_a7a80834016864ae22e9f95f6478a5c2.bundle)
2022/07/21 02:46:24.281 18827 18869 Info Unity AddressablesPlayAssetDelivery.PlayAssetDeliveryInitializeOperation:AppBundleTransformFunc(IResourceLocation)
2022/07/21 02:46:24.281 18827 18869 Info Unity UnityEngine.ResourceManagement.ResourceProviders.AssetBundleRequestOptions:ComputeSize(IResourceLocation, ResourceManager)
2022/07/21 02:46:24.281 18827 18869 Info Unity UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource:get_BytesToDownload()
2022/07/21 02:46:24.281 18827 18869 Info Unity UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource:GetDownloadStatus()
2022/07/21 02:46:24.281 18827 18869 Info Unity UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation1:SetDownloadProgressCallback(Func1)
2022/07/21 02:46:24.281 18827 18869 Info Unity UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource:Start(ProvideHandle)
2022/07/21 02:46:24.281 18827 18869 Info Unity UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider:Provide(ProvideHandle)
2022/07/21 02:46:24.281 18827 18869 Info Unity UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1:Execute()

Now, in the AAB file, the file path is

/AFSFastFollow/assets/map_assets_all_a7a80834016864ae22e9f95f6478a5c2.bundle

I even copied the asset packs directly from my phone after deployment, and AFSFastFollow-master.apk has the same file path. The bundle files exist there.

Why is it trying to load the incorrect file path, and how do I specify the correct one? Is it as simple as changing the Asset group's Load path? I tried doing that and it didn't work but maybe I need to specify something specific?

Current Project:

  • Unity 2021.3.6f1 (also tried 2021.3.4 and 2021.3.1)
  • Addressables 1.19.19

Any ideas on how to get this fast-follow pack to load properly? I think it should be referencing AFSFastFollow.apk, not split_UnityDataAssetPack.apk, as the former is the fast-follow data and the latter is the install-time data. The install-time data works fine.

Here is the AAB file structure
image

Removing a Specific Child Object in a Content Update Causes an Error.

I posted this on the Unity Forums https://forum.unity.com/threads/unusual-behaviour-removing-a-specific-child-object-in-a-content-update-causes-an-error.1285517/ but I decided to put this as an issue for people to notice here.

The details are in the link above. To summarize the context and the problem:
Context: Using Addressables with remote content delivery via Google Cloud Storage (Bucket created using Firebase) and testing it with Unity-chan package fbx models.
Steps:

  1. Create a prefab with the "unitychan" 3D fbx model as a child object.
  2. Build content, upload content into cloud, build player, and play on Android to see it all work fine.
  3. Update the prefab by changing the child object "unitychan" 3D fbx model into something else. A sphere, cube, or whatever.
  4. Update existing build and upload it to cloud.
  5. Play on Android.

Expected result: prefab is updated with whatever was replaced.
What happens: Addressable scene does not even load and this error appears in the Android logcat:
image

SpaceShooter DynamicInvoke error while playing

Hi, I am new to Addressables and wanted to try the samples in this repo,
When I tried to open SpaceShooter with unity version 2021.2.5f1 and played the bootstrap scene, after few frames I got the following exception in console:

Exception thrown in DynamicInvoke: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at UnityEngine.ResourceManagement.ResourceProviders.AssetDatabaseProvider.LoadAssetAtPath (System.String assetPath, UnityEngine.ResourceManagement.ResourceProviders.ProvideHandle provideHandle) [0x00013] in C:\GitLab\Addressables-Sample\Basic\SpaceShooter\Library\PackageCache\[email protected]\Runtime\ResourceManager\ResourceProviders\AssetDatabaseProvider.cs:46 
  at UnityEngine.ResourceManagement.ResourceProviders.AssetDatabaseProvider+InternalOp.LoadImmediate () [0x000c6] in C:\GitLab\Addressables-Sample\Basic\SpaceShooter\Library\PackageCache\[email protected]\Runtime\ResourceManager\ResourceProviders\AssetDatabaseProvider.cs:112 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <00c558282d074245ab3496e2d108079b>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <00c558282d074245ab3496e2d108079b>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <00c558282d074245ab3496e2d108079b>:0 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e7] in <00c558282d074245ab3496e2d108079b>:0 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in <00c558282d074245ab3496e2d108079b>:0 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <00c558282d074245ab3496e2d108079b>:0 
  at UnityEngine.ResourceManagement.Util.DelayedActionManager+DelegateInfo.Invoke () [0x00000] in C:\GitLab\Addressables-Sample\Basic\SpaceShooter\Library\PackageCache\[email protected]\Runtime\ResourceManager\Util\DelayedActionManager.cs:46  5 (target=UnityEngine.ResourceManagement.ResourceProviders.AssetDatabaseProvider+InternalOp) InternalOp.LoadImmediate() @7.347976
UnityEngine.ResourceManagement.Util.DelayedActionManager:LateUpdate () (at Library/PackageCache/[email protected]/Runtime/ResourceManager/Util/DelayedActionManager.cs:159)

any suggestions to why it would happen? when I click unpause it resume and then thrown again :(

Thanks!

SyncBundleProvider never actually releases bundles.

Investigating the possible use of the sync addressables for a PC game production, I noticed that bundles were actually never released from memory. A quick investigation designated the SyncBundleProvider as the culprit.

It does not override the Release method, which tries to cast our SyncAssetBundleResource into a AssetBundleResource.

Adding the two documented methods -Unload and Release- in the code sample below seemingly fixes the issue!

public class SyncBundleProvider : AssetBundleProvider
{

    class SyncAssetBundleResource : IAssetBundleResource
    {
        AssetBundle m_AssetBundle;

        public AssetBundle GetAssetBundle()
        {
            return m_AssetBundle;
        }

        internal void Start(ProvideHandle provideHandle)
        {
            m_AssetBundle = AssetBundle.LoadFromFile(provideHandle.Location.InternalId);
            if(m_AssetBundle == null)
                Debug.LogError("the bundle failed " + provideHandle.Location.InternalId);
            provideHandle.Complete(this, m_AssetBundle != null, null);
        }

        /// <summary>
        /// Unloads all resources associated with this asset bundle.
        /// </summary>
        public void Unload()
        {
            if (m_AssetBundle != null)
            {
                m_AssetBundle.Unload(true);
                m_AssetBundle = null;
            }
        }
    }
    
    public override void Provide(ProvideHandle providerInterface)
    {
        new SyncAssetBundleResource().Start(providerInterface);
    }

    /// <inheritdoc/>
    public override void Release(IResourceLocation location, object asset)
    {
        if (location == null)
            throw new ArgumentNullException("location");
        if (asset == null)
        {
            Debug.LogWarningFormat("Releasing null asset bundle from location {0}.  This is an indication that the bundle failed to load.", location);
            return;
        }
        var bundle = asset as SyncAssetBundleResource;
        if (bundle != null)
        {
            bundle.Unload();
            return;
        }
        return;
    }
}

Sync addressables dont work in 2019.3.15f, addressables version 1.9.2

Getting the following error in the build:

NullReferenceException: Object reference not set to an instance of an object
  at UnityEngine.ResourceManagement.AsyncOperations.InitalizationObjectsOperation.Execute () [0x00014] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\Initialization\InitializationObjectsOperation.cs:29 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () [0x00001] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:413 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) [0x00076] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:407 
  at UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) [0x00001] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\ResourceManager\ResourceManager.cs:411 
  at UnityEngine.AddressableAssets.Initialization.InitializationOperation.CreateInitializationOperation (UnityEngine.AddressableAssets.AddressablesImpl aa, System.String playerSettingsLocation, System.String providerSuffix) [0x000c5] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\Initialization\InitializationOperation.cs:59 
  at UnityEngine.AddressableAssets.AddressablesImpl.InitializeAsync (System.String runtimeDataPath, System.String providerSuffix, System.Boolean autoReleaseHandle) [0x00110] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\AddressablesImpl.cs:394 
  at UnityEngine.AddressableAssets.AddressablesImpl.InitializeAsync () [0x00001] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\AddressablesImpl.cs:403 
  at UnityEngine.AddressableAssets.Addressables.InitializeAsync () [0x00001] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Library\PackageCache\[email protected]\Runtime\Addressables.cs:270 
  at SyncAddressables.Init () [0x00001] in C:\Users\tjheuvel\Downloads\Addressables-Sample-master\Advanced\Sync Addressables\Assets\SyncAddressables\SyncAddressables.cs:19 
 

Error - JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll

  • need

    • need remove jetbrain dlls (or remove Plugins folder)
    • ~/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll
  • Errror Msg
    Assembly 'Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll' will not be loaded due to errors: Assembly name 'JetBrains.Rider.Unity.Editor.Plugin.Full.Repacked' does not match file name 'JetBrains.Rider.Unity.Editor.Plugin.Repacked'

  • IDE

    • JetBrains Rider 2022.1.1
    • Unity 2021.3.0f1

Request to PGS failed because all packs are unavailable

Hi,
I follow the sample to integrate play asset Delivery. And upload to play store. I got some error log just like below when I launch game which is download from google play store. Is something wrong?

Unity version 2021.3.12f1
Addressables version : 1.19.19
Play core : 1.7.0

Finsky : [77377] gxs.a(8): Request execution failed with error code: -2 12-08 18:54:21.134 5920 15353 E Finsky : com.google.android.finsky.assetmoduleserviceutils.AssetModuleException: Request to PGS failed because all packs are unavailable. 12-08 18:54:21.134 5920 15353 E Finsky : at hhp.hr(Unknown Source:4) 12-08 18:54:21.134 5920 15353 E Finsky : at fhr.q(Unknown Source:55) 12-08 18:54:21.134 5920 15353 E Finsky : at dhn.run(PG:2) 12-08 18:54:21.134 5920 15353 E Finsky : at android.os.Handler.handleCallback(Handler.java:914) 12-08 18:54:21.134 5920 15353 E Finsky : at android.os.Handler.dispatchMessage(Handler.java:100) 12-08 18:54:21.134 5920 15353 E Finsky : at android.os.Looper.loop(Looper.java:224) 12-08 18:54:21.134 5920 15353 E Finsky : at android.app.ActivityThread.main(ActivityThread.java:7560) 12-08 18:54:21.134 5920 15353 E Finsky : at java.lang.reflect.Method.invoke(Native Method) 12-08 18:54:21.134 5920 15353 E Finsky : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 12-08 18:54:21.134 5920 15353 E Finsky : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 12-08 18:54:21.137 15265 15333 V FA : Connection attempt already in progress 12-08 18:54:21.137 15265 15333 V FA : Connection attempt already in progress 12-08 18:54:21.137 15265 15341 I PlayCore: UID: [12009] PID: [15265] AssetPackServiceImpl : Leaving the connection open for other ongoing calls. 12-08 18:54:21.137 15265 15333 D FA : Connected to remote service 12-08 18:54:21.137 15265 15341 E PlayCore: UID: [12009] PID: [15265] AssetPackServiceImpl : onError(-2) 12-08 18:54:21.138 15265 15333 V FA : Processing queued up service tasks: 7 12-08 18:54:21.138 15265 15349 I PlayCore: UID: [12009] PID: [15265] AssetPackServiceImpl : getChunkFileDescriptor(CustomFastFollow, CustomFastFollow, 0, session=47) 12-08 18:54:21.139 5920 5939 I Finsky : [77086] hec.h(2): getChunkFileDescriptor for package: com.joypoppuzzle.homeblock, chunkId: AssetModuleChunkId{sessionId=47, moduleName=CustomFastFollow, sliceId=CustomFastFollow, chunkIndex=0}

The BuildProcessorData.json and CustomAssetPacksData.json not generated

I ran Build > New Build > Play Asset Delivery

Looked into the PlayAssetDelivery folder -> Build and those files are not there. Moreover, the files which were there got deleted.
Is that correct? It doesn't seem to match what was in the description for this project.

Moreover, aren't the *.bundle files also be placed under the PlayAssetDelivery -> Build folder? I don't see them placed there too.

Build error (bundle does not exist) when building Play Asset Delivery

I'm receiving an error when building the Play Asset Delivery. My version of Addressables is at 1.18.15. I'm also using the exact Unity version (2020.3.15f2) that the sample uses. When I select Build > New Build > Play Asset Delivery, I receive this error:

Library/com.unity.addressables/aa/Android/Android/mountainartstatic_assets_all.bundle does not exist
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
     
Addressable content build failure (duration : 0:00:00)
UnityEditor.GenericMenu:CatchMenu (object,string[],int)

It seems to occur on the first addressable group with "FastFolowContent". AlI of my groups have the Asset Bundle Provider set to use the “Play Asset Delivery Provider”. I tried a few different methods to fix this, such as setting different Bundle Naming Modes on that group, changing the compression method, shortening the name of the group, etc... This is what the offending group looks like.

image

Any ideas?

Play Asset Delivery example breaks when using ARCore package

Hello!

I see the disclaimer that these examples are not guaranteed to work, but I am seeing a very strange issue when trying to use Addressables with Play Asset Delivery.

It seems like splitting the application binary causes an issue with the Unity Android build where a copy of UnitySubsystemsManifest.json is duplicated in both the base APK and the generated asset pack. I have only seen this happen while using the ARCore XR plugin so far.

Steps to reproduce:

  1. Open the PlayAssetDelivery SampleScene
  2. Install ARCore XR Plugin 4.1.7 or 4.2.0 through the Unity package manager UI
  3. Go through the setup steps as described in the Addressables-Sample project's README
  4. Ensure 'Split Application Binary' is checked in Player / Publishing settings
  5. Build the AAB

In a shell script:

bundletool="java -jar bundletool-all-1.8.0.jar"
$bundletool build-apks --bundle=$name.aab --output=$name.apks
$bundletool install-apks --apks=$name.apks

When I don't split the application binary, everything works fine! But when I do, I get the following error:

[BT:1.8.0] Error: Both modules 'base' and 'UnityDataAssetPack' contain asset entry 'assets/bin/Data/UnitySubsystems/UnityARCore/UnitySubsystemsManifest.json'.
com.android.tools.build.bundletool.model.exceptions.InvalidBundleException: Both modules 'base' and 'UnityDataAssetPack' contain asset entry 'assets/bin/Data/UnitySubsystems/UnityARCore/UnitySubsystemsManifest.json'.
        at com.android.tools.build.bundletool.model.exceptions.UserExceptionBuilder.build(UserExceptionBuilder.java:58)
        at com.android.tools.build.bundletool.validation.EntryClash
   ....

Unity version: 2020.3.15f2
Bundletool version: 1.8.0

Example of someone seeing the same issue: https://answers.unity.com/questions/1859871/unityarcore-android-app-bundle-split-binary-issue.html

The Addressable plugin's Analyze tool does not seem to mention this issue. (same warnings in both situations, never related to ARCore or Subsystems)

I can provide more information as needed. The issue is fairly simple to reproduce, the only difference is that the ARCore plugin is installed.

ENABLE_CACHING and how to disable caching is never explained.

Disabling caching is essential for development, but is explained nowhere. The release notes mention ENABLE_CACHING, but without explanation. The documentation hints at disabling caching, but without explanation.

I found over 10 questions on Unity forums etc. of users trying to disable caching or deleting entries from the cache. They were all struggling, and none of those questions where answered.

How do you disable caching?

WaitForCompletion() not working?

`[ServerRpc]
private void ServerSpawnPlayer()
{
GameObject playerPrefab = Addressables.LoadAssetAsync("Player").WaitForCompletion();

    GameObject playerInstance = Instantiate(playerPrefab);

    Spawn(playerInstance, Owner);
}`

why is this line red? "Addressables.LoadAssetAsync("Player")"

please do not suggest me the link below because ı wrote same thing on the linked example, everything is the same, nothing changes !. I use 2021.1.6f1 version. Please fix the bug as soon as possible.

https://docs.unity3d.com/Packages/[email protected]/manual/SynchronousAddressables.html#api

SyncAddressables sample doesn't work 2019.4.17f1 with Addressibles 1.16.16

The SyncAddress sample code doesn't work when loading multiple prefabs.
Simple Repro: Change the FixedUp code to load 2 cubes and the exception throws with the load percentage at 0.5

Exception: Sync Instantiate has null result Cube
SyncAddressables.Instantiate (System.Object key, UnityEngine.Transform parent, System.Boolean instantiateInWorldSpace) (at Assets/SyncAddressables/SyncAddressables.cs:120)
spawner.FixedUpdate () (at Assets/spawner.cs:35)

Repro:

    if (m_Counter == 10)
      {
        var go = SyncAddressables.Instantiate("Cube");
        go.transform.forward = new Vector3(Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180));
        m_instances.Add(go);
        
        go = SyncAddressables.Instantiate("Cube");
        go.transform.forward = new Vector3(Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180));
        m_instances.Add(go);

Play Asset Delivery sample silently fails if bundle names conflict

The Play Asset Delivery example has a number of issues, such as failing silently if a bundle name already exists during build. So if you have the same bundle name in two different paths, when it condenses it all down into the PlayAssetDelivery/Build folder it conflicts and throws an error that you never see because the build process clears the console window afterward. This exception handler is also outside of the loop, so it just fails and skips the rest of the bundles entirely instead of ignoring the conflicting bundle. This causes the PAD build process to abort but the rest of the build to continue, so you end up with a broken build containing only some of your assets and no indication as to why.

See PlayAssetDeliveryBuildProcessor.cs (MoveDataForAppBundleBuild)

So if you are building and yet only some bundles are actually making it into the AAB file even though it seems to succeed, this could be why. This is also across ALL groups so if one group has the problem, any subsequent groups will not build.

Update a previous build fails every time with the example unity addressables demos

Unity: 2019.2.7f2
Addressables: 1.3.3 and 1.3.8

Update a previous build fails every time with the example unity addressables demos

  1. How we can reproduce it using the example you attached

Window->asset management->Addressables->groups

Build->update a previous build
point to: AddressableAssetsData\Windows->addressables_content_state.bin

in recent releases of addressables this always fails

tested with both 1.3.3 and 1.3.8 of addressables

Tested with Bundle naming set to: Append Hash, No Hash, and Only Hash. It fails the same way with all 3 settings

Dump:

FileNotFoundException: Library/BuildCache/b1/b1ecc6112fa791c152b4b447d215d591/3a3c198b9b43f5ecb13fd72358de6006/cff6f55b67135de451348b26e8a5b9a8_assets_done_bolt-enemy.bundle_f4d87e80087fef875556e834572f714d does not exist
System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
UnityEditor.Build.Pipeline.Tasks.ArchiveAndCompressBundles.SetOutputInformation (System.String writePath, System.String finalPath, System.String bundleName, UnityEngine.Build.Pipeline.BundleDetails details) (at Library/PackageCache/[email protected]/Editor/Tasks/ArchiveAndCompressBundles.cs:204)
UnityEditor.Build.Pipeline.Tasks.ArchiveAndCompressBundles.Run () (at Library/PackageCache/[email protected]/Editor/Tasks/ArchiveAndCompressBundles.cs:189)
UnityEditor.Build.Pipeline.BuildTasksRunner.Run (System.Collections.Generic.IList`1[T] pipeline, UnityEditor.Build.Pipeline.Interfaces.IBuildContext context) (at Library/PackageCache/[email protected]/Editor/Shared/BuildTasksRunner.cs:50)
UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32) (at C:/buildslave/unity/build/Editor/Mono/GUI/GenericMenu.cs:121)

Loading/Unloading Addressable Prefabs based on Camera Location

On this forum here, this is mentioned:

In our own prototyping the best model we've come up with is a script that takes all the game objects on a scene, makes them prefabs, then replaces them with a proxy. That proxy can then have a script on it that instantiates the addressable prefab based on the camera's location. We don't yet have a clean and shareable version of this script, but are working on a demo to put in our Samples github.

Is this the repo that code would be in? I can't seem to find it. I'm trying to do something like this in order to help with memory management for a webgl build, so even having the non-clean version of wherever that was left off at would be helpful.

Thanks!

error display before enter the game

there is my steps:
Test.cs:

using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.U2D;
using UnityEngine.UI;

public class Test : Image
{
// Start is called before the first frame update
protected override void Start()
{
base.Start();

    Addressables.LoadAssetAsync<SpriteAtlas>("Atlas/hero.spriteatlas").Completed += OnCompleted;
}
void OnCompleted(AsyncOperationHandle<SpriteAtlas> op)
{
    sprite = op.Result.GetSprite("hero_icon_004");

    Addressables.Release(op);
}

}

then,play the game in editor, everything right.
but exit the game ,hide unity window and reopen editor window(just refresh) ,
the "hero_icon_004" show in the scene(not playing!)

image

i guess something woring with inherit the UIBehaviour,

Official untested examples?

I got to this repo from the Unity's official Addressables how-to page: https://unity.com/how-to/simplify-your-content-management-addressables, where it says:

Where can I learn more about Addressables?
If you want to use Addressables in your project, check out the Addressable Asset System documentation to learn how to get started. Read our blog post, check out the GitHub Samples, or join the discussions on forums.

Where the "GitHub Samples" link leads to this repo. And now I get to this repo and what do I see? The first paragraph of the readme literally says:

These are intended as jumping off points for your own development. These have not been tested, and are not guaranteed to work in your situation. They are just examples, to make some concepts easier to understand, or easier to replicate in your own project. Use at your own risk.

At the moment of writing this:

  • the last commit to the repo was made 3 months ago, which brought some small fix to one of the examples (a824d02)
  • the previous commit before that was 11 months ago

The issue I have with all this is: what am I even implied to think about all this?! Why Unity does not take care to keep a working, verified, updated and guaranteed set of examples of one of its most important new features?

Am I supposed to use these examples, or does Unity know beforehand that they are suboptimal and do not reflect the way of doing things? Why are we left with these examples then? Why doesn't anyone at Unity make real examples that are tested, guaranteed to work and are not risky to use?

Can Unity please make sure that the examples for using its advertised technologies and features are up-to-date, working and are safe to refer to and use when looking to learn the aforementioned technologies?

How to resume download

I use DownloadDependenciesAsync to download assets.
It doesn't work when I reset network, I hold an AsyncOperationHandler and it's TaskStatus is WaittingToRun.
How can I resume download or stop the AsyncOperationHandler.
Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.