public void CheckFirstHull(HullListEntry.ButtonPress changeHullCallBack) { if (HullList.Count > 0) { changeHullCallBack(HullList[0].hullData); } SelectionIndex = 0; }
public ShipHullScrollList(Rect rect, HullListEntry.ButtonPress changeHullCallBack, CheckHullValid checkHulls) { ScrollWindowRect = rect; ScrollViewRect = new Rect(0, 0, ScrollWindowRect.width * 0.92f, ScrollWindowRect.height * 1.02f); ScrollPosition = Vector2.zero; HullList.Clear(); float EntrySize = ScrollViewRect.width / 5f; int index = 0; foreach (KeyValuePair <string, ShipHullData> keyVal in ResourceManager.GetShipHulls()) { if (checkHulls(keyVal.Value)) { Rect entryRect = new Rect(EntrySize * (HullList.Count % 5), EntrySize * (HullList.Count / 5), EntrySize, EntrySize); HullListEntry HLE = new HullListEntry(entryRect, keyVal.Value, index, changeHullCallBack, ChangeSelectionIndex); HullList.Add(HLE); index++; } } ScrollViewRect.height = Mathf.Max(ScrollWindowRect.height * 1.02f, EntrySize * (HullList.Count / 5 + (HullList.Count % 5 != 0 ? 1 : 0))); }