반응형
- 코드 작성
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
public class Example : MonoBehaviour
{
const string DownloadURL = "https://docs.google.com/spreadsheets/d/" + "주소 Id 값" + "/export?format=tsv&gid=0";
void Awake()
{
StartCoroutine(DownloadFile());
}
IEnumerator DownloadFile()
{
Debug.Log("File Downloading...");
UnityWebRequest www = UnityWebRequest.Get(DownloadURL);
yield return www.SendWebRequest();
File.WriteAllText(GetPath() + "FileName.txt", www.downloadHandler.text);
Debug.Log("File Download Complete!");
}
public string GetPath()
{
string path = null;
switch (Application.platform)
{
case RuntimePlatform.Android:
path = Application.persistentDataPath;
path = path.Substring(0, path.LastIndexOf('/'));
return Path.Combine(Application.persistentDataPath, "Resources/");
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
path = Application.persistentDataPath;
path = path.Substring(0, path.LastIndexOf('/'));
return Path.Combine(path, "Assets", "Resources/");
case RuntimePlatform.WindowsEditor:
path = Application.dataPath;
path = path.Substring(0, path.LastIndexOf('/'));
return Path.Combine(path, "Assets", "Resources/");
default:
path = Application.dataPath;
path = path.Substring(0, path.LastIndexOf('/'));
return Path.Combine(path, "Resources/");
}
}
}
참고할만한 글
반응형