Created
October 7, 2021 09:30
-
-
Save TakaakiIchijo/6dee37ede0905363bd7d29020440b164 to your computer and use it in GitHub Desktop.
ADX for UnityのacbファイルをUnity Cloud Content Deliveryからダウンロード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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