Skip to content

Commit 8605531

Browse files
author
Pim de Witte
authored
Merge pull request PimDeWitte#2 from Fireforge/master
Added overloaded Enqueue(Action action)
2 parents cd0755b + ec29437 commit 8605531

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

UnityMainThreadDispatcher.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ public void Enqueue(IEnumerator action) {
4646
});
4747
}
4848
}
49+
50+
/// <summary>
51+
/// Locks the queue and adds the Action to the queue
52+
/// </summary>
53+
/// <param name="action">function that will be executed from the main thread.</param>
54+
public void Enqueue(Action action)
55+
{
56+
Enqueue(ActionWrapper(action));
57+
}
58+
IEnumerator ActionWrapper(Action a)
59+
{
60+
a();
61+
yield return null;
62+
}
4963

5064

5165
private static UnityMainThreadDispatcher _instance = null;

0 commit comments

Comments
 (0)