Skip to content

Instantly share code, notes, and snippets.

@Trissiklikk
Last active March 31, 2024 07:36
Show Gist options
  • Save Trissiklikk/a010237e2d64db62419616f3973d73af to your computer and use it in GitHub Desktop.
Save Trissiklikk/a010237e2d64db62419616f3973d73af to your computer and use it in GitHub Desktop.
HelperWaitForSeconds.cs
using UnityEngine;
using System.Collections.Generic;
public static class HelperWaitForSeconds
{
static readonly Dictionary<float, WaitForSeconds> WaitForSeconds = new Dictionary<float, WaitForSeconds>();
/// <summary>
/// This method is used to get WaitForSeconds clss with the specified seconds with out creating new WaitForSeconds.
/// </summary>
/// <param name="seconds"></param>
/// <returns></returns>
public static WaitForSeconds Get(float seconds)
{
if (!WaitForSeconds.ContainsKey(seconds))
WaitForSeconds.Add(seconds, new WaitForSeconds(seconds));
return WaitForSeconds[seconds];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment