I have multiple scenes each can be downloaded from addressable. If a scene is completed downloaded , loading scene has no issue, however any of the scene download is on progress ,other downloaded scene has pink sprite.
Here the code that downloads the scene.
public class AddreasableSceneThumbnail : MonoBehaviour
{
[SerializeField] string sceneAddress;
[SerializeField] Transform downloadProgressUI;
bool isDownloadStarted;
bool isDownloaded;
IEnumerator downloadCour;
private void Start()
{
StartCoroutine(CheckDownload());
}
private void OnDestroy()
{
if(downloadCour != null)
StopCoroutine(downloadCour);
if (downloadHandlerCheck.IsValid())
{
Addressables.Release(downloadHandlerCheck);
}
if (downloadHandlerDownload.IsValid())
{
Addressables.Release(downloadHandlerDownload);
}
}
AsyncOperationHandle<long> downloadHandlerCheck;
IEnumerator CheckDownload()
{
downloadHandlerCheck = Addressables.GetDownloadSizeAsync(sceneAddress);
while (!downloadHandlerCheck.IsDone && downloadHandlerCheck.Status !=AsyncOperationStatus.Failed)
{
yield return null;
}
if (downloadHandlerCheck.Result == 0)
{
ActivateButton();
isDownloaded = true;
}
Addressables.Release(downloadHandlerCheck);
}
public void OnThumbNailClicked()
{
if(isDownloaded)
Addressables.LoadSceneAsync(sceneAddress,LoadSceneMode.Single);
if (isDownloadStarted) return;
isDownloadStarted = true;
downloadCour= DownloadScene();
StartCoroutine(downloadCour);
}
AsyncOperationHandle downloadHandlerDownload;
IEnumerator DownloadScene()
{
downloadProgressUI.transform.localScale = Vector3.one;
downloadProgressUI.gameObject.SetActive(true);
downloadHandlerDownload = Addressables.DownloadDependenciesAsync(sceneAddress);
while (!downloadHandlerDownload.IsDone)
{
downloadProgressUI.localScale = new Vector3(1, 1 - downloadHandlerDownload.PercentComplete, 1);
yield return null;
}
isDownloaded = true;
ActivateButton();
Addressables.Release(downloadHandlerDownload); //this is culprit
}
public void ActivateButton()
{
downloadProgressUI.gameObject.SetActive(false);
}
}
I think there is some issue with builtin shader not being loaded on addreasable, however i could not find any solution to it. The issue is on android build.
Note: Issue occurs when i release the handle, however not releasing handle doesnot load the scene into memory.