/// <summary> /// Gets the pixel regions of <paramref name="atlas"/> and sorts them using <paramref name="sortType"/>. /// </summary> /// <param name="atlas">The <see cref="dfAtlas"/> to get the pixel regions from.</param> /// <param name="sortType">The <see cref="AtlasItemSortType"/> used to sort the list of pixel regions.</param> /// <returns>A list with all pixel regions in <paramref name="atlas"/> that is sorted using <paramref name="sortType"/></returns> public static List <RectInt> GetSortedPixelRegions(this dfAtlas atlas, AtlasItemSortType sortType) { List <RectInt> rawList = atlas.GetPixelRegions(); List <RectInt> sortedList = new List <RectInt>(); while (sortedList.Count < rawList.Count) { RectInt rint = new RectInt(0, 0, 0, 0); bool rintIsUnassigned = true; for (int i = 0; i < rawList.Count; i++) { if (!sortedList.Contains(rawList[i])) { if (rintIsUnassigned) { rint = rawList[i]; rintIsUnassigned = false; } else { rint = ((rint.GetPointInRint(sortType).x >= rawList[i].GetPointInRint(sortType).x&& rint.GetPointInRint(sortType).y >= rawList[i].GetPointInRint(sortType).y) ? rawList[i] : rint); } } } sortedList.Add(rint); } return(sortedList); }