first commit
This commit is contained in:
commit
aa44d3ad70
1585 changed files with 277994 additions and 0 deletions
35
Assets/Plugins/CodeAssist/Editor/MainThreadDispatcher.cs
Normal file
35
Assets/Plugins/CodeAssist/Editor/MainThreadDispatcher.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
#nullable enable
|
||||
|
||||
|
||||
namespace Meryel.UnityCodeAssist.Editor
|
||||
{
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class MainThreadDispatcher
|
||||
{
|
||||
readonly static ConcurrentBag<System.Action> actions;
|
||||
|
||||
static MainThreadDispatcher()
|
||||
{
|
||||
actions = new ConcurrentBag<System.Action>();
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
static void Update()
|
||||
{
|
||||
while (actions.TryTake(out var action))
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Add(System.Action action) => actions.Add(action);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue