public static Texture2D GetIcon(this icon icon) { if (_managementIcons == null) { _managementIcons = new List <Texture2D>(); } var ind = (int)icon; while (_managementIcons.Count <= ind) { _managementIcons.Add(null); } if (_managementIcons[ind] != null) { return(_managementIcons[ind]); } switch (icon) { case icon.Red: return(ColorIcon(0) as Texture2D); case icon.Green: return(ColorIcon(1) as Texture2D); case icon.Blue: return(ColorIcon(2) as Texture2D); case icon.Alpha: return(ColorIcon(3) as Texture2D); default: return(icon.Load()); } }