using System; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; namespace Dott.Editor { public static class DottExtensions { public static void ForEach(this IEnumerable source, Func func) { foreach (var element in source) { func(element); } } public static T GetRandom(this IList collection) { return collection[Random.Range(0, collection.Count)]; } public static int IndexOf(this IList array, T value) { return array.IndexOf(value); } public static int FindIndex(this IList array, Func predicate) { for (var i = 0; i < array.Count; i++) { if (predicate(array[i])) { return i; } } return -1; } public static bool IsRightMouseButton(this Event @event) { const int mouseButtonLeft = 0; if (Application.platform == RuntimePlatform.OSXEditor && @event.control && @event.button == mouseButtonLeft) { return true; } const int mouseButtonRight = 1; return @event.button == mouseButtonRight; } } }