您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

31 行
890 B

using System;
using System.IO;
using System.Threading.Tasks;
using UnityEngine;
namespace Unity.Services.Core
{
static class StreamingAssetsUtils
{
public static Task<string> GetFileTextFromStreamingAssetsAsync(string path)
{
var fullPath = Path.Combine(Application.streamingAssetsPath, path);
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_WEBGL)
return UnityWebRequestUtils.GetTextAsync(fullPath);
#else
var completionSource = new TaskCompletionSource<string>();
try
{
var fileText = File.ReadAllText(fullPath);
completionSource.SetResult(fileText);
}
catch (Exception e)
{
completionSource.SetException(e);
}
return completionSource.Task;
#endif
}
}
}