Skip to content

Instantly share code, notes, and snippets.

@TakaakiIchijo
Created October 7, 2021 09:30
Show Gist options
  • Save TakaakiIchijo/6dee37ede0905363bd7d29020440b164 to your computer and use it in GitHub Desktop.
Save TakaakiIchijo/6dee37ede0905363bd7d29020440b164 to your computer and use it in GitHub Desktop.
ADX for UnityのacbファイルをUnity Cloud Content Deliveryからダウンロード
public class DownloadAcbFromUnityCCD : MonoBehaviour
{
public CriAtomSource atomSource;
public string cueSheetName = {cuesheet name};
public string cueName = {cue name};
public string addressableRemotePathUrl = {Addressable Remote Path Url};
private IEnumerator Start()
{
var request = UnityWebRequest.Get(addressableRemotePathUrl+cueSheetName+".acb");
string savePath = Path.Combine(Application.persistentDataPath, cueSheetName+".acb");
request.downloadHandler = new DownloadHandlerFile(savePath);
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success)
{
CriAtom.AddCueSheet(cueSheetName, savePath, null, null);
Debug.Log("Download Success");
while (CriAtom.CueSheetsAreLoading) {
yield return null;
}
Debug.Log("Load Success");
atomSource.cueSheet = cueSheetName;
atomSource.cueName = cueName;
atomSource.Play();
}
else
{
Debug.Log("request error "+ request.result);
}
}
private void OnDestroy()
{
string savePath = Path.Combine(Application.persistentDataPath, cueSheetName+".acb");
File.Delete(savePath);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment