store application.datapath on initialize #86

master
neuecc 2020-06-06 14:21:31 +09:00
parent 686394c861
commit 265f88584b
3 changed files with 24 additions and 7 deletions

View File

@ -239,7 +239,7 @@ namespace Cysharp.Threading.Tasks.Internal
} }
else else
{ {
var fname = fi.FullName.Replace(Path.DirectorySeparatorChar, '/').Replace(Application.dataPath, ""); var fname = fi.FullName.Replace(Path.DirectorySeparatorChar, '/').Replace(PlayerLoopHelper.ApplicationDataPath, "");
var withAssetsPath = "Assets/" + fname; var withAssetsPath = "Assets/" + fname;
return "<a href=\"" + withAssetsPath + "\" line=\"" + line + "\">" + withAssetsPath + ":" + line + "</a>"; return "<a href=\"" + withAssetsPath + "\" line=\"" + line + "\">" + withAssetsPath + ":" + line + "</a>";
} }

View File

@ -92,8 +92,10 @@ namespace Cysharp.Threading.Tasks
{ {
public static SynchronizationContext UnitySynchronizationContext => unitySynchronizationContetext; public static SynchronizationContext UnitySynchronizationContext => unitySynchronizationContetext;
public static int MainThreadId => mainThreadId; public static int MainThreadId => mainThreadId;
internal static string ApplicationDataPath => applicationDataPath;
static int mainThreadId; static int mainThreadId;
static string applicationDataPath;
static SynchronizationContext unitySynchronizationContetext; static SynchronizationContext unitySynchronizationContetext;
static ContinuationQueue[] yielders; static ContinuationQueue[] yielders;
static PlayerLoopRunner[] runners; static PlayerLoopRunner[] runners;
@ -177,6 +179,11 @@ namespace Cysharp.Threading.Tasks
// capture default(unity) sync-context. // capture default(unity) sync-context.
unitySynchronizationContetext = SynchronizationContext.Current; unitySynchronizationContetext = SynchronizationContext.Current;
mainThreadId = Thread.CurrentThread.ManagedThreadId; mainThreadId = Thread.CurrentThread.ManagedThreadId;
try
{
applicationDataPath = Application.dataPath;
}
catch { }
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER #if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
// When domain reload is disabled, re-initialization is required when entering play mode; // When domain reload is disabled, re-initialization is required when entering play mode;

View File

@ -302,15 +302,25 @@ public class SandboxMain : MonoBehaviour
return 10; return 10;
} }
async UniTask<int> Ex()
{
await UniTask.Yield();
//throw new Exception();
await UniTask.Delay(TimeSpan.FromSeconds(15));
return 0;
}
void Start() void Start()
{ {
//_ = UniTask.Run(async () => _ = Ex();
//{
// var watch = System.Diagnostics.Stopwatch.StartNew(); _ = UniTask.Run(async () =>
// await UniTask.Delay(new TimeSpan(0, 0, seconds: 10)); {
// Debug.Log(watch.Elapsed); var watch = System.Diagnostics.Stopwatch.StartNew();
//}); await UniTask.Delay(new TimeSpan(0, 0, seconds: 10));
Debug.Log(watch.Elapsed);
});
//return; //return;
//await UniTask.SwitchToMainThread(); //await UniTask.SwitchToMainThread();