반응형
- 코드 작성
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/");
}
}
}
참고할만한 글
반응형
'개발 > C#' 카테고리의 다른 글
유니티 C# 애플 로그인 Sign ln with Apple Login 간단 구현 (0) | 2022.08.17 |
---|---|
유니티 C# 비속어 필터 적용 inputfield 간단 사용법 (0) | 2022.07.14 |
유니티 C# 디버그 로그 종류 Debug.Log 간단 사용법 (0) | 2022.07.13 |
유니티 C# 자주 사용하는 연산자 Operator 모음 (0) | 2022.07.13 |
유니티 C# 오디오 Audio Source , Audio Clip 간단 사용법 (0) | 2022.07.06 |
유니티 C# 카메라 흔들기 Camera Shake 간단 사용법 (0) | 2022.07.06 |
유니티 C# 시간 DateTime 출력하기 간단 사용법 (0) | 2022.07.06 |
유니티 C# 코루틴 Coroutine 간단 사용법 (0) | 2022.07.06 |
댓글