2019-05-30 18:41:23 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
2019-05-19 23:14:47 +08:00
|
|
|
|
using System.Collections.Generic;
|
2020-04-15 14:23:23 +08:00
|
|
|
|
using System.IO;
|
2020-04-19 02:38:30 +08:00
|
|
|
|
using System.Text;
|
2019-05-30 18:41:23 +08:00
|
|
|
|
using System.Threading;
|
2020-04-18 04:07:59 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2019-05-19 23:14:47 +08:00
|
|
|
|
using UniRx.Async;
|
|
|
|
|
using UnityEngine;
|
2019-05-30 18:41:23 +08:00
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
using UnityEngine.UI;
|
2019-05-19 23:14:47 +08:00
|
|
|
|
|
|
|
|
|
public class SandboxMain : MonoBehaviour
|
|
|
|
|
{
|
2019-05-30 18:41:23 +08:00
|
|
|
|
public Button okButton;
|
|
|
|
|
public Button cancelButton;
|
2020-04-18 04:07:59 +08:00
|
|
|
|
public Text text;
|
|
|
|
|
|
2019-05-30 18:41:23 +08:00
|
|
|
|
CancellationTokenSource cts;
|
2019-05-19 23:14:47 +08:00
|
|
|
|
|
2020-04-19 02:24:53 +08:00
|
|
|
|
UniTaskCompletionSource ucs;
|
2020-04-18 04:07:59 +08:00
|
|
|
|
|
|
|
|
|
void Start()
|
2019-05-19 23:14:47 +08:00
|
|
|
|
{
|
2020-05-05 04:22:49 +08:00
|
|
|
|
var playerLoop = UnityEngine.LowLevel.PlayerLoop.GetCurrentPlayerLoop();
|
|
|
|
|
ShowPlayerLoop.DumpPlayerLoop("Current", playerLoop);
|
|
|
|
|
|
|
|
|
|
//for (int i = 0; i < 14; i++)
|
|
|
|
|
//{
|
|
|
|
|
// TimingDump((PlayerLoopTiming)i).Forget();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//StartCoroutine(CoroutineDump("yield WaitForEndOfFrame", new WaitForEndOfFrame()));
|
|
|
|
|
//StartCoroutine(CoroutineDump("yield WaitForFixedUpdate", new WaitForFixedUpdate()));
|
|
|
|
|
//StartCoroutine(CoroutineDump("yield null", null));
|
2020-04-18 04:07:59 +08:00
|
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
|
|
Application.logMessageReceived += Application_logMessageReceived;
|
|
|
|
|
|
|
|
|
|
|
2020-04-19 02:24:53 +08:00
|
|
|
|
ucs = new UniTaskCompletionSource();
|
2020-04-18 04:07:59 +08:00
|
|
|
|
|
2020-04-18 21:11:40 +08:00
|
|
|
|
okButton.onClick.AddListener(async () =>
|
2020-04-18 04:07:59 +08:00
|
|
|
|
{
|
2020-04-18 21:11:40 +08:00
|
|
|
|
await InnerAsync(false);
|
|
|
|
|
});
|
2020-04-18 04:07:59 +08:00
|
|
|
|
|
|
|
|
|
cancelButton.onClick.AddListener(async () =>
|
|
|
|
|
{
|
|
|
|
|
text.text = "";
|
|
|
|
|
|
2020-05-04 00:59:22 +08:00
|
|
|
|
// ucs.TrySetResult();
|
2020-04-18 04:07:59 +08:00
|
|
|
|
|
|
|
|
|
await ucs.Task;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 04:22:49 +08:00
|
|
|
|
async UniTask TimingDump(PlayerLoopTiming timing)
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
await UniTask.Yield(timing);
|
|
|
|
|
Debug.Log("PlayerLoopTiming." + timing);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator CoroutineDump(string msg, YieldInstruction waitObj)
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
yield return waitObj;
|
|
|
|
|
Debug.Log(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//private void Update()
|
|
|
|
|
//{
|
|
|
|
|
// Debug.Log("Update");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//private void LateUpdate()
|
|
|
|
|
//{
|
|
|
|
|
// Debug.Log("LateUpdate");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//private void FixedUpdate()
|
|
|
|
|
//{
|
|
|
|
|
// Debug.Log("FixedUpdate");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
2020-04-18 04:07:59 +08:00
|
|
|
|
private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
|
|
|
|
|
{
|
|
|
|
|
text.text += "\n" + condition;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 02:24:53 +08:00
|
|
|
|
async UniTask OuterAsync(bool b)
|
2020-04-18 04:07:59 +08:00
|
|
|
|
{
|
|
|
|
|
UnityEngine.Debug.Log("START OUTER");
|
|
|
|
|
|
|
|
|
|
await InnerAsync(b);
|
|
|
|
|
await InnerAsync(b);
|
|
|
|
|
|
|
|
|
|
UnityEngine.Debug.Log("END OUTER");
|
|
|
|
|
|
|
|
|
|
// throw new InvalidOperationException("NAZO ERROR!?"); // error!?
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 02:24:53 +08:00
|
|
|
|
async UniTask InnerAsync(bool b)
|
2020-04-18 04:07:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (b)
|
|
|
|
|
{
|
|
|
|
|
UnityEngine.Debug.Log("Start delay:" + Time.frameCount);
|
2020-04-19 02:24:53 +08:00
|
|
|
|
await UniTask.DelayFrame(60);
|
2020-04-18 04:07:59 +08:00
|
|
|
|
UnityEngine.Debug.Log("End delay:" + Time.frameCount);
|
2020-04-19 02:24:53 +08:00
|
|
|
|
await UniTask.DelayFrame(60);
|
2020-04-18 04:07:59 +08:00
|
|
|
|
UnityEngine.Debug.Log("Onemore end delay:" + Time.frameCount);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-18 21:11:40 +08:00
|
|
|
|
UnityEngine.Debug.Log("Empty END");
|
|
|
|
|
throw new InvalidOperationException("FOOBARBAZ");
|
2020-04-18 04:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-30 18:41:23 +08:00
|
|
|
|
|
2020-05-05 04:22:49 +08:00
|
|
|
|
/*
|
|
|
|
|
PlayerLoopTiming.Initialization
|
|
|
|
|
PlayerLoopTiming.LastInitialization
|
|
|
|
|
PlayerLoopTiming.EarlyUpdate
|
|
|
|
|
PlayerLoopTiming.LastEarlyUpdate
|
|
|
|
|
PlayerLoopTiming.PreUpdate
|
|
|
|
|
PlayerLoopTiming.LastPreUpdate
|
|
|
|
|
PlayerLoopTiming.Update
|
|
|
|
|
Update
|
|
|
|
|
yield null
|
|
|
|
|
yield WaitForSeconds
|
|
|
|
|
yield WWW
|
|
|
|
|
yield StartCoroutine
|
|
|
|
|
PlayerLoopTiming.LastUpdate
|
|
|
|
|
PlayerLoopTiming.PreLateUpdate
|
|
|
|
|
LateUpdate
|
|
|
|
|
PlayerLoopTiming.LastPreLateUpdate
|
|
|
|
|
PlayerLoopTiming.PostLateUpdate
|
|
|
|
|
PlayerLoopTiming.LastPostLateUpdate
|
|
|
|
|
yield WaitForEndOfFrame
|
2020-04-15 14:23:23 +08:00
|
|
|
|
|
2020-05-05 04:22:49 +08:00
|
|
|
|
// --- Physics Loop
|
|
|
|
|
PlayerLoopTiming.FixedUpdate
|
|
|
|
|
FixedUpdate
|
|
|
|
|
yield WaitForFixedUpdate
|
|
|
|
|
PlayerLoopTiming.LastFixedUpdate
|
|
|
|
|
*/
|
2020-04-18 04:07:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// e.SetObserved();
|
|
|
|
|
// or other custom write code.
|
|
|
|
|
UnityEngine.Debug.LogError("Unobserved:" + e.Exception.ToString());
|
2019-05-19 23:14:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-30 18:41:23 +08:00
|
|
|
|
|
2020-04-19 02:38:30 +08:00
|
|
|
|
public class ShowPlayerLoop
|
|
|
|
|
{
|
2020-05-05 04:22:49 +08:00
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
2020-04-19 02:38:30 +08:00
|
|
|
|
static void Init()
|
|
|
|
|
{
|
|
|
|
|
var playerLoop = UnityEngine.LowLevel.PlayerLoop.GetDefaultPlayerLoop();
|
2020-05-05 04:22:49 +08:00
|
|
|
|
DumpPlayerLoop("Default", playerLoop);
|
|
|
|
|
}
|
2020-04-19 02:38:30 +08:00
|
|
|
|
|
2020-05-05 04:22:49 +08:00
|
|
|
|
public static void DumpPlayerLoop(string which, UnityEngine.LowLevel.PlayerLoopSystem playerLoop)
|
|
|
|
|
{
|
2020-04-19 02:38:30 +08:00
|
|
|
|
var sb = new StringBuilder();
|
2020-05-05 04:22:49 +08:00
|
|
|
|
sb.AppendLine($"{which} PlayerLoop List");
|
2020-04-19 02:38:30 +08:00
|
|
|
|
foreach (var header in playerLoop.subSystemList)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat("------{0}------", header.type.Name);
|
|
|
|
|
sb.AppendLine();
|
|
|
|
|
foreach (var subSystem in header.subSystemList)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat("{0}.{1}", header.type.Name, subSystem.type.Name);
|
|
|
|
|
sb.AppendLine();
|
2020-05-05 04:22:49 +08:00
|
|
|
|
|
|
|
|
|
if (subSystem.subSystemList != null)
|
|
|
|
|
{
|
|
|
|
|
UnityEngine.Debug.LogWarning("More Subsystem:" + subSystem.subSystemList.Length);
|
|
|
|
|
}
|
2020-04-19 02:38:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnityEngine.Debug.Log(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|