Search Unity

Why Addressable assets are not working when packed play mode is used.

Discussion in 'Addressables' started by GMonks-Entertainment, Apr 20, 2019.

  1. GMonks-Entertainment

    GMonks-Entertainment

    Joined:
    Sep 25, 2014
    Posts:
    7
    I am working on Android platform on unity 2019.1.0f2 and using Addressable assets version 0.6.8. Addressable assets are working fine when using fast mode or virtual mode but as soon as I switch to packed play mode, it just stops working when I hit play. following are the steps I am performing before hitting Play.

    1. I am using Default profile.
    2. I have added assets in Default local group.
    3. I have hit build player content in Addressables tab.

    This is script I am using

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using UnityEngine.AddressableAssets;
    4. using UnityEngine.ResourceManagement.AsyncOperations;
    5.  
    6. public class LoadSprite : MonoBehaviour
    7. {
    8.     void Start()
    9.     {
    10.         Addressables.LoadAsset<Sprite>("1").Completed += LoadImage;
    11.     }
    12.  
    13.     void LoadImage(IAsyncOperation<Sprite> sprite)
    14.     {
    15.         GetComponent<Image>().sprite = sprite.Result;
    16.         Addressables.ReleaseAsset(sprite.Result);
    17.     }
    18. }
    I have downgraded to 0.6.7 and 0.6.6 also but getting same result.
     

    Attached Files:

  2. GMonks-Entertainment

    GMonks-Entertainment

    Joined:
    Sep 25, 2014
    Posts:
    7
    Addressables.ReleaseAsset(sprite.Result); seems to be creating problem here. After removing it, it started working again. Same code was working in previous version 0.4.6.
     
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    I'm mostly sure that the old "working" version was the bug. You are basically doing this...
    1. load texture into memory
    2. tell a sprite to look at that texture in memory
    3. remove texture from memory

    now the sprite is looking for something that has gone away. You need to keep that thing loaded as long as it's being used.