Skip to content

Instantly share code, notes, and snippets.

@JohannesLoot
Created February 8, 2022 10:29
Show Gist options
  • Save JohannesLoot/754bdbe6107d9a78f1842c125aee57ab to your computer and use it in GitHub Desktop.
Save JohannesLoot/754bdbe6107d9a78f1842c125aee57ab to your computer and use it in GitHub Desktop.
public void GetCorrectWordsFromCloud(int fileIndex)
{
string[] list = new string[] { "89852" };
LootLockerSDKManager.GetAssetsById(list, (response) =>
{
if (response.success)
{
Debug.Log("Successfully retrieved " + response.assets.Length + " assets");
Debug.Log("First Asset ID: " + response.assets[0].id);
// Does the file exist?
if (response.assets[0].files[fileIndex] != null)
{
// Get the file requested by the index
StartCoroutine(GetFileRoutine(response.assets[0].files[fileIndex].url));
}
}
else
{
Debug.Log("Error retrieving assets");
}
});
}
public IEnumerator GetFileRoutine(string url)
{
using (UnityWebRequest www = UnityWebRequest.Get(url))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
{
Debug.Log(www.error);
}
else
{
wordlist = www.downloadHandler.text;
hasWordList = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment