Skip to content

Commit

Permalink
ready for 2.0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Jul 29, 2020
1 parent e947464 commit 2e35324
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/UniTask/Assets/Plugins/UniTask/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.cysharp.unitask",
"displayName": "UniTask",
"version": "2.0.26",
"version": "2.0.27",
"unity": "2018.4",
"description": "Provides an efficient async/await integration to Unity.",
"keywords": [ "async/await", "async", "Task", "UniTask" ],
Expand Down
43 changes: 34 additions & 9 deletions src/UniTask/Assets/Scenes/SandboxMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void Increment(int value)
async UniTask RunStandardDelayAsync()
{



UnityEngine.Debug.Log("DEB");

Expand Down Expand Up @@ -223,9 +223,9 @@ async UniTask RunJobAsync()

async UniTaskVoid Update2()
{








Expand Down Expand Up @@ -464,7 +464,7 @@ async void Nanika()

private void Awake()
{
PlayerLoopInfo.Inject();
// PlayerLoopInfo.Inject();
PrepareCamera();
}

Expand All @@ -482,12 +482,24 @@ public IUniTaskAsyncEnumerable<int> MyEveryUpdate()
});
}

async void RunStandardTaskAsync()
{
Debug.Log("Wait 3 seconds");
await Task.Delay(TimeSpan.FromSeconds(3));

Debug.Log("Current SyncContext:" + SynchronizationContext.Current.GetType().FullName);
}


async UniTaskVoid Start()
{
var url = "http://google.com/404";
var webRequestAsyncOperation = UnityWebRequest.Get(url).SendWebRequest();
await webRequestAsyncOperation.ToUniTask();
RunStandardTaskAsync();

UnityEngine.Debug.Log("UniTaskPlayerLoop ready? " + PlayerLoopHelper.IsInjectedUniTaskPlayerLoop());

//var url = "http://google.com/404";
//var webRequestAsyncOperation = UnityWebRequest.Get(url).SendWebRequest();
//await webRequestAsyncOperation.ToUniTask();

//PlayerLoopInfo.Inject();

Expand Down Expand Up @@ -694,7 +706,9 @@ async UniTaskVoid Start()

//StartCoroutine(Coroutine());

//await UniTask.Delay(TimeSpan.FromSeconds(1));
// PlayerLoopInfo.Inject();
await UniTask.Delay(TimeSpan.FromSeconds(1));
PlayerLoopInfo.DumpPlayerLoop("current", PlayerLoop.GetCurrentPlayerLoop());


// _ = ReturnToMainThreadTest();
Expand Down Expand Up @@ -1060,6 +1074,17 @@ async UniTask ShootAsync()
}
}


public class SyncContextInjecter
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
public static void Inject()
{
SynchronizationContext.SetSynchronizationContext(new UniTaskSynchronizationContext());
}
}


public class PlayerLoopInfo
{
// [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
Expand Down Expand Up @@ -1094,7 +1119,7 @@ public static void DumpPlayerLoop(string which, UnityEngine.LowLevel.PlayerLoopS

public static Type CurrentLoopType { get; private set; }

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
// [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
public static void Inject()
{
var system = PlayerLoop.GetCurrentPlayerLoop();
Expand Down

0 comments on commit 2e35324

Please sign in to comment.