Exemplo n.º 1
0
 private void FixedUpdate()
 {
     if (FixedUpdateScheduler == null)
     {
         UpdateScheduler = new UnityTaskScheduler("Update");
     }
     FixedUpdateScheduler = new UnityTaskScheduler("FixedUpdate");
 }
Exemplo n.º 2
0
 private void LateUpdate()
 {
     if (LateUpdateScheduler == null)
     {
         LateUpdateScheduler = new UnityTaskScheduler("LateUpdate");
     }
     LateUpdateScheduler.Activate();
 }
Exemplo n.º 3
0
 private void Update()
 {
     if (UpdateScheduler == null)
     {
         UpdateScheduler = new UnityTaskScheduler("Update");
     }
     UpdateScheduler.Activate();
 }
Exemplo n.º 4
0
    private static void Initialize()
    {
        MainThreadId = Thread.CurrentThread.ManagedThreadId;

        UpdateScheduler      = new UnityTaskScheduler("Update");
        LateUpdateScheduler  = new UnityTaskScheduler("LateUpdate");
        FixedUpdateScheduler = new UnityTaskScheduler("FixedUpdate");

        SynchronizationContext.SetSynchronizationContext(UpdateScheduler.Context);

        var go = new GameObject("UnityScheduler");

        go.hideFlags = HideFlags.HideAndDontSave;
        go.AddComponent <UnityScheduler>();
    }
Exemplo n.º 5
0
	private void Awake()
	{
		if (Instance != null)
		{
			throw new NotSupportedException("UnityScheduler already exists.");
		}
		Instance = this;
		MainThreadId = Thread.CurrentThread.ManagedThreadId;

		DontDestroyOnLoad(gameObject);

		UpdateScheduler = new UnityTaskScheduler("Update");
		LateUpdateScheduler = new UnityTaskScheduler("LateUpdate");
		FixedUpdateScheduler = new UnityTaskScheduler("FixedUpdate");

		SynchronizationContext.SetSynchronizationContext(UpdateScheduler.Context);
	}
Exemplo n.º 6
0
    private void Awake()
    {
        if (Instance != null)
        {
            throw new NotSupportedException("UnityScheduler already exists.");
        }
        Instance     = this;
        MainThreadId = Thread.CurrentThread.ManagedThreadId;

        DontDestroyOnLoad(gameObject);

        UpdateScheduler      = new UnityTaskScheduler("Update");
        LateUpdateScheduler  = new UnityTaskScheduler("LateUpdate");
        FixedUpdateScheduler = new UnityTaskScheduler("FixedUpdate");

        SynchronizationContext.SetSynchronizationContext(UpdateScheduler.Context);
    }
    private IEnumerator Start()
    {
        UnityTaskScheduler.Initialize();

        var task = Task.Run(() => print("First action."))
                   .ContinueWith(t => print("wait for click"))
                   .ContinueWith(WaitForClick()) // <- IEnumerator
                   .ContinueWith(new WaitForSeconds(1))
                   .ContinueWith(t =>
        {
            print("Second action.");
        })
                   .ContinueWith(new WaitForSeconds(1))
                   .ContinueWith(t =>
        {
            print("Third action.");
        });

        yield return(task);

        print("All done!");
    }
Exemplo n.º 8
0
 public static void InitializeInEditor()
 {
     MainThreadId          = Thread.CurrentThread.ManagedThreadId;
     EditorUpdateScheduler = new UnityTaskScheduler("EditorUpdate");
     SynchronizationContext.SetSynchronizationContext(EditorUpdateScheduler.Context);
 }