Search Unity

issue, problem loading addressable that have been added by code

Discussion in 'Addressables' started by unity_hrZ38HF8Y_GAVQ, Jan 31, 2020.

  1. unity_hrZ38HF8Y_GAVQ

    unity_hrZ38HF8Y_GAVQ

    Joined:
    Aug 18, 2019
    Posts:
    8
    I try to use addressable to stream chunks of unity terain, but when i create addressable(Prefab) via code and try to load/instantiate i got error
    Code (CSharp):
    1. Exception encountered in operation Resource<GameObject>(chunk [int2(1, -2)].prefab): Unknown error in AsyncOperation
    2. UnityEngine.ResourceManagement.Util.DelayedActionManager:LateUpdate() (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/Util/DelayedActionManager.cs:169)
    Code (CSharp):
    1. Exception encountered in operation UnityEngine.AddressableAssets.Initialization.InitializationOperation, result='', status='Succeeded' - Chain<GameObject>: ChainOperation of Type: UnityEngine.GameObject failed because dependent operation failed
    2. Unknown error in AsyncOperation
    3. UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1:OnWrappedCompleted(AsyncOperationHandle`1)
    4. DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/Util/DelegateList.cs:69)
    5. UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    6. MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)
    7.  
    code used to add entry
    Code (CSharp):
    1. AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;
    2. AddressableAssetGroup group = settings.DefaultGroup;
    3. List<AddressableAssetEntry> list = new List<AddressableAssetEntry>();
    4. AddressableAssetEntry e = settings.CreateOrMoveEntry(guid, group , false , true);
    5. settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved , e , true);
    in set dirty method i try to pass list of one entry as "eventData" and i change modification event addedEntry but still dosnt work.
    when i add addressableentry via editor everythink is working

    Unity 2019.30f3 addressables 1.6

    thank you for help, and sorry for poor grammar
     
  2. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Just double checking, how are you getting the guid and are you sure that's correct?
     
  3. unity_hrZ38HF8Y_GAVQ

    unity_hrZ38HF8Y_GAVQ

    Joined:
    Aug 18, 2019
    Posts:
    8
    Code (CSharp):
    1.  
    2.                     string name = "chunk [" + vec + "]";
    3.                     GameObject gm = new GameObject();
    4.                     gm.name = name;
    5.                     string path = prefabFolder + "/" + name + ".prefab";
    6.                     PrefabUtility.SaveAsPrefabAsset(gm, path , out bool succes);
    7.                     if ( ! succes)
    8.                     {
    9.                         Debug.LogWarning("ops");
    10.                         return;
    11.                     }
    12.                     string guid = AssetDatabase.AssetPathToGUID(path);
    13.  
    i will try to found problem inside my code
     
  4. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Ah, I see a potential problem. In your prefab naming you use "[" and "]". When you add via code, Addressables is going to use the path of the asset as the address of the thing by default. We have to disallow using square brackets inside of address names in order to support the sub objects feature of the Editor.

    Something to try: change your square brackets to some other delineation. Or when you add the asset to Addressables, try changing its address to something that doesn't use the square brackets.

    Hope that helps. Let me know if you still have trouble.
     
    unity_hrZ38HF8Y_GAVQ likes this.