Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Addressables are here!

Discussion in 'Addressables' started by audrey-unity, Jun 15, 2018.

  1. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    94
    Hello,
    I am struggling with events in Addressables. Because of the lack of a simple syncronized load method.
    ----------
    **What happens if I override the variable textureHandle before it triggered?**
    The previous delegate is deleted and not notified anymore, or It will trigger twice?
    are they considered two different events?
    ----------
    Code (CSharp):
    1.      AsyncOperationHandle<GameObject> textureHandle = Addressables.LoadAssetAsync<GameObject>("AssetAddress");
    2.         textureHandle.Completed += ElementToNotify1.TextureHandle_Completed;
    3.  
    4.         AsyncOperationHandle<GameObject> textureHandle = Addressables.LoadAssetAsync<GameObject>("AssetAddress");
    5.         textureHandle.Completed += ElementToNotify2.TextureHandle_Completed;
    ----------
    P.S. This code is in a class named DataManager.
    I have a class Dog and a class Cat, I need both to spawn a poo gameobject, with addressable.

    I would like to write in Dog and Cat classes a method LoadPooAsync() that will call the DataManager and pass to them their object reference so, when the object is loaded it will trigger the event for the right object who asked for it.
    I tried to write something with Actions but didn't work..
    Could you help me to write the methods signatures?
     
  2. ConfusedExpert

    ConfusedExpert

    Joined:
    Dec 25, 2014
    Posts:
    7
    Hello.
    I have a question about the caching system for remote bundles.
    When I try to run my app without internet connection, the app eventually loads the latest copies found in the cache.
    But it takes the app 300 seconds approx to do so.
    I am unsure how I can change this. I'd like it to give up much faster and go grab the copies from the cache, especially if there is no internet connection.
    Or maybe even load the cached version while checking if a new one is available.

    Does anyone know how I can achieve this?
     
  3. rastlin

    rastlin

    Joined:
    Jun 5, 2017
    Posts:
    127
    @LeleUnity
    In above code, you have two separate events, to whom you subscribed, they will fire independently for each of your notify classes.

    Someone already pointed out to you, you don't need to load the same asset twice, you can subscribe to the Completed method twice, it's a delegate.

    If you need the assets to be loaded synchronously, you could just do:
    Code (csharp):
    1.  
    2. var asyncResult = Addressables.LoadAssetAsync<GameObject>("AssetAddress");
    3. await asyncResult.Task;
    4.  
     
  4. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    94
    I can't Use Async Addressables. I don't want to use Sync addressable since is not recommended and not supported in WebGL. I want to use the Async version.

    I have a structure where:
    Character1Holder---->LevelManager---->DataBaseManager
    Character2Holder----->LevelManager--->DataBase Manager

    The 2 charcter holders calls a method "give me character named X/Y and send a callback to me When loaded" respectively. So it will pass both the name of the desired charcter to be loaded and the reference of themselves to be called when the load is completed.

    The levelManager just passes the request to the DatabaseManager that base on the wanted prefab it will load it asynchronsly. Then, thanks to the reference to the Character1Holder it will register a call back method.
    This is the code of the method inside the DataBaseManager.



    Code (CSharp):
    1. AsyncOperationHandle<GameObject> CharacterHandle= Addressables.LoadAssetAsync<GameObject>("CharacterX");
    2.  
    3. CharacterHandle.Completed += CharacterXObjectReference.CharacterHasBeenLoadedCallBack;
    The problem is:
    What will happen IF this Charcter1 calls this method, and Charcter2 calls this method too before the
    Code (CSharp):
    1. Character1ObjectReference.CharacterHasBeenLoadedCallBack
    is triggered ?

    The variable CharacterHandle will be overriden with the data of Charcter2.
    This will delete the previous subscribtion to the event? or both triggers will be registered to the event of the loaded charcter1 ?
    What happens if I override the variable CharacterHandlebefore it is triggered?**
    The previous delegate is deleted and not notified anymore, or It will trigger twice?
    are they considered two different events?
     
  5. zbyhoo

    zbyhoo

    Joined:
    Nov 18, 2013
    Posts:
    17
    Does anyone have problems with saving settings of Addressable Asset Settings within Unity editor?

    After couple days of trying to make addressables working, I accounter situation, that I have to manually change settings files, like AddressableAssetSettings.asset, because modifying inside the editor is not reflected in file change.

    Using Unity 2018.4.23, addressables package 1.8.3
     
  6. zbyhoo

    zbyhoo

    Joined:
    Nov 18, 2013
    Posts:
    17
    I have also a second problem, maybe connected to what I've described above.
    Everything works in Unity editor (even with Play Mode Script set to "Use existing build" with remote load path set to our CND hosting server), but it does not work in iOS or Android build.

    It fails with the message:
    Exception encountered in operation Resource<IAssetBundleResource>(here is bundle name): RemoteAssetBundleProvider unable to load from url (here is proper url), result='Unknown Error'.​

    I double-check the file to download, and URL specified is correct. It downloads bundles in a web browser. The binary diff shows no differences between download file and local file generated with addressable build process.
     
  7. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    94
    how can a ScriptableObject be loaded with addressables?
     
  8. wwaero

    wwaero

    Joined:
    Feb 18, 2020
    Posts:
    33
    When I click the addressable checkbox it locks up my unity for a very long time. What is happening while my unity is locked? I'm trying to make a large 1.5gb file addressable, is this a bad idea?
     
  9. IndieFist

    IndieFist

    Joined:
    Jul 18, 2013
    Posts:
    415
    Can i ask something simple?
    The correct way to implement with occlusion and light are these steps:
    1.- difference not interactable or referenced elements with high texture .
    2.- do bake of lights and occlusion
    3.- made it addressable these elements and use it when player trigger near or something like that?

    I was some days reading all and i was a bit confused with that.
     
  10. PontosYu

    PontosYu

    Joined:
    May 20, 2020
    Posts:
    9
    Hello,I have a question about LoadAssetAsync();
    this API is too slow to downloaded asset if the bundle large,maybe 50M or bigger.
    It's that problem based on AssetBundle? WebRequest or else?
    Code (CSharp):
    1. var startTime= Date.Now;
    2. Addressables.LoadAssetAsync<GameObject>(label).Complected+=obj=>
    3. {
    4.   //It may take 40s or more when files bigger than 20M
    5.   Debug.Log("TotalTimes"+(Date.Now-startTime).TotalSeconds);
    6. }
    7.  
    Hope someone can tell me why Addressable load very slow.Thanks
     
    Last edited: Jun 9, 2020
  11. sinaari

    sinaari

    Joined:
    Jan 28, 2019
    Posts:
    25
    I'm having the same problem.. Have you been able to find out what's wrong?
     
  12. PontosYu

    PontosYu

    Joined:
    May 20, 2020
    Posts:
    9
    I'm not sure.
    I thought it might locate the asset too slow on Server?But on AWS or GCP still slowly so I think it's unity's problem.
    LZ4 and LZMA compress format possible casue the issue,you can try no compreess,LZ4 and LZMA to test.
    Whatever I tried path or label still too slow!
    If the issue is the UnityWebRequest cause,I can't do anything...
    Maybe try System.WebClient to download asset....
    I hope someone like Unity Technologies can help us.
    This problem cause me can't use AAS in my company project.:(
     
    Last edited: Jun 9, 2020
  13. Tsotne991

    Tsotne991

    Joined:
    Jun 15, 2018
    Posts:
    2
    Hello, Everyone
    I added the addressable later in the game development and for some reasons I cant get it working properly with the sliced sprites. In not sliced sprites it works normally, but in sliced sprites it cant recognize the sliced object and gives reference to the hole Texture itself. What can be the problem be?
    Thank you in Advance
     
  14. IndieFist

    IndieFist

    Joined:
    Jul 18, 2013
    Posts:
    415
    Sorry for bumping, but i want some tips or best practices for starting with addressables in mobile ;)
     
  15. fabioColombini

    fabioColombini

    Joined:
    Dec 9, 2013
    Posts:
    23
    Any tip on Scriptable Objects and Addressables?

    Our game is based on SO to communicate between systems, but with addressables, it seems that the SO loses its contents.
     
  16. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    459
    Scriptable Objects function the same as GameObjects. I use them with addressables without issue.
     
  17. deltamish

    deltamish

    Joined:
    Nov 1, 2012
    Posts:
    57
    Problem with using RemoteLoading for Addressables (Works in Editor but not in build)
    Issue:
    Exception encountered in operation Dependencies: Invalid path in AssetBundleProvider: 'D:/Work/Projects/Unity/AddressableSystemTest/Builds/WinBuild4/AddressableSystemTest_Data/StreamingAssets/aa/StandaloneWindows/defaultlocalgroup_unitybuiltinshaders_240b781245634e4879740700defc2878.bundle'.
    UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:LogFormat(LogType, String, Object[])
    UnityEngine.Debug:LogErrorFormat(String, Object[])

    My goal is to load new assets from server into my scene.
    I have a script called loader that does Addressables.LoadAssetAsync<Object>("robot").

    I have set up the RemoteLoadPath to point to my S3 and RemoteBuildPath as default.

    Steps I followed were:
    1. Download Robot-Kyle asset
    2. Move it into Addressable group while having remote profile active.
    3. Changed address as robot
    4. Build the Script
    5. Build the application
    6. Copy paste contents from /ServerData/StandalonWindows into S3 bucket with public flag
    7. Runs in Editor. Works in build
    8.Now I downloaded a new asset. Added it to the group.
    9. renamed old one as soemthing else and renamed New Asset as "robot"
    10. Build Addressables using UpdateFromPreviousBuild
    11. repeat step 6
    12. Run in Editor. Works
    13. Run the build. Error I pasted above is thrown.
    14. Did a ton of research no valid answer that works


    upload_2020-6-27_14-50-51.png
     
  18. Ayodhya1991

    Ayodhya1991

    Joined:
    Apr 24, 2017
    Posts:
    3
    Hi Everyone,

    As i am going through Addressable assets Implementation from all the Videos i found following steps:
    1.Download addressable package.
    2.Create prefab which has to be marked as Addressable. Then mark is as Addressable asset and Build it to addressable local path / Cloud path.
    3.Load it with the Asyc method provided [Here the prefab stays in the Project itself].

    What i tried to implement.
    1. Created a Unity Project Say "Project 01" and i build few addressable assets.
    2. Loaded addressable assets from local as well as Cloud path But Here the prefabs are present in the project itself.
    3. I was able to load the assets from local as well as cloud path.
    4. Next i have created another empty unity project "Project 02" with addressable asset settings.
    5. In "Project 02" i have given path for Cloud location to fetch it with the same scripts as "Project 01".
    6. But i not able to do so.

    Please let me know what are the steps need to be followed to implement following Use case.

    Use case.
    1. I want to create 2 unity project "Project 01" & "Project 02" environments where one would be Development environment from which i would like to build and upload Addressable Assets to Cloud.
    2. Another project would be Production ready where i will fetch all the Addressable Assets created from Project 01 to Project 02 with the same cloud path where Addressable Assets are uploaded.

    Thanks.
     
  19. mars_jang

    mars_jang

    Joined:
    Jul 1, 2020
    Posts:
    2
    Hello, I am trying to create a group template with script completely.

    And now I could create a template and assign the build / load paths,
    but I have no idea how to assign the 'Asset Provider' and 'AssetBundle Provider' fields.

    Anyone can help ?
    Addressable version: 1.8.4

    snapshot.png

    Code (CSharp):
    1. [MenuItem("Marscat/Addressable/Init")]
    2. private static void InitTemplates()
    3. {
    4.     var settings = AddressableAssetSettingsDefaultObject.Settings;
    5.     settings.GroupTemplateObjects.Clear();
    6.  
    7.     var groupSchemaTypes = new[] {typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)};
    8.     settings.CreateAndAddGroupTemplate("PackTemplate", "A description", groupSchemaTypes);
    9.  
    10.     var newTemplate = settings.GetGroupTemplateObject(0) as AddressableAssetGroupTemplate;
    11.     InitGroupTemplate(newTemplate, "LocalBuildPath", "LocalLoadPath", true, BundlePackingMode.PackTogether);
    12.  
    13.     AssetDatabase.SaveAssets();
    14.  
    15.     void InitGroupTemplate(AddressableAssetGroupTemplate template, string buildPath, string loadPath, bool includeInBuild, BundlePackingMode packingMode)
    16.     {
    17.         var bundleSchema = template.GetSchemaByType(typeof(BundledAssetGroupSchema)) as BundledAssetGroupSchema;
    18.         bundleSchema.BuildPath.SetVariableByName(settings, buildPath);
    19.  
    20.         bundleSchema.LoadPath.SetVariableByName(settings, loadPath);
    21.         bundleSchema.IncludeInBuild = includeInBuild;
    22.         bundleSchema.BundleMode     = packingMode;
    23.         bundleSchema.BundleNaming   = BundledAssetGroupSchema.BundleNamingStyle.NoHash;
    24.  
    25.         EditorUtility.SetDirty(bundleSchema);
    26.     }
    27. }
    28.  
     
    Last edited: Jul 21, 2020
  20. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    319
    I have an issue that whenever i mark the prefabs as addressable and go to new build > default build script afterwards i have to clean the cache and rebuild it if i want my prefabs to be spawned like they appear in the project view. Otherwise, a previous version is spawned.
     
  21. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    228
    Hello I am new to Addressables.
    I am having a problem getting a AssetReferenceSprite.

    I have 1000's of scriptable objects that reference Sprites.
    I am writing a script to populate a new field with the AssetReferenceSprite in it.
    I did something similar for my prefabs and it worked great.
    But I can't figure out how to the the AssetReferenceSprite back for the Sprite object.

    Here is some code that may help you understand what I am doing.

    Code (CSharp):
    1.     void OnWizardCreate()
    2.     {
    3.         UnityEngine.Object[] objects = Resources.LoadAll(path, typeof(ScriptableObject));
    4.  
    5.         foreach (UnityEngine.Object cd in objects)
    6.         {
    7.             ConditionData data = cd as ConditionData;
    8.  
    9.             if (data == null)
    10.                 continue;
    11.  
    12.             data.iconReference = data.icon.GetAssetReference() as AssetReferenceSprite;
    13.  
    14.             EditorUtility.SetDirty(cd);
    15.         }
    16.  
    17.         AssetDatabase.SaveAssets();
    18.  
    19.     }
    Code (CSharp):
    1.         public static AssetReference GetAssetReference(this Object o)
    2.         {
    3.             string guid = string.Empty;
    4.             long localID = 0;
    5.  
    6.             bool foundAsset = AssetDatabase.TryGetGUIDAndLocalFileIdentifier(o, out guid, out localID);
    7.  
    8.             if (foundAsset)
    9.                 return AddressableAssetSettingsDefaultObject.Settings.CreateAssetReference(guid);
    10.  
    11.             return null;
    12.         }

    Any help would be great.
     
  22. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    228
    Ok I got it working by adding this method to "AddressableAssetSettings".

    Code (CSharp):
    1.         public AssetReferenceSprite CreateAssetReferenceSprite(string guid)
    2.         {
    3.             CreateOrMoveEntry(guid, DefaultGroup);
    4.             return new AssetReferenceSprite(guid);
    5.         }
    They may have been a way to get it without adding this method but I could not figure it out.
     
  23. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    822
    Addvatage of scene.load async or addressables load?

    On a local storage I want to load several different screens with content.

    Now my question is, what has the better over a performance ? Scene.load async or addressables loading a Scene?

    The loading processing should be as smooth as possible in the background.

    Does anyone have experience with?
    Thanks!
     
  24. HamidDjavadi

    HamidDjavadi

    Joined:
    Sep 21, 2020
    Posts:
    1
    When you build your bundles using addressable system, the output contains these stuff:

    1. a hash file
    2. catalogue of your assets (local + remote)
    3. remote bundles (but not local)
    The problem is: after unity building and releasing in store, when you change a local asset and build using addressable system and put it on server again, the hash of your local in catalogue will change (without having that local bundle on server) and that causes client to update local asset hashes without having the related bundles, as a result not loading those assets.

    What is the reason of putting local asset addresses in remote catalogue while you do not have local bundles on remote?
     
    Last edited: Sep 27, 2020
  25. pavelmo4alov

    pavelmo4alov

    Joined:
    Mar 13, 2013
    Posts:
    12
    Hello! Are there any way to load prefab with scripts from addressable bundle, if bundle build by another project ? Prefab with mesh and materials load correctly but script is missing. If I copy script to this project and load prefab - all is good.
     
  26. JasperCiti

    JasperCiti

    Joined:
    Jul 5, 2013
    Posts:
    8
    I noticed that if I create a scene with static GameObjects and I make that scene addressable: Then when I load the scene directly in the editor the static GameObjects are static, but when I load the scene as an addressable asset, the all the static GameObjects are loaded as non-static GameObjects.

    Is that per design or a bug?

    I was using Addressables 1.16.1
     
unityunity