반응형
- 코드 작성
using System.IO;
using UnityEngine;
public static class SystemPath
{
public static string GetPath(string fileName) //파일 위치 불러오기
{
string path = GetPath();
return Path.Combine(GetPath(), fileName);
}
public static 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/");
}
}
}
반응형