⌛MEC
More Effective Coroutines is an improved implementation of coroutines that runs about twice as fast as Unity’s coroutines do and has zero per-frame memory allocations.
Examples
Simple Delayed Action
using MEC;
public void OnPlayerChangingRole(PlayerChangingRoleEventArgs args)
{
Timing.CallDelayed(3f, () =>
{
args.Player.Position = Vector3.zero;
});
}Simple Coroutine
using MEC;
public IEnumerator<float> MyCoroutine(Player player) // You can pass arguments
{
player.Role = RandomRoles.GetOne();
yield return Timing.WaitForSeconds(5); // Stops execution for 5 seconds
player.ShowBroadcast("See you in the next frame!");
yield return Timing.WaitForOneFrame; // Stops execution for 1 frame
player.ShowBroadcast("There you are!")
}Simple Loop
Last updated