public void Populate() { selectedDice = new HashSet <Die>(); availableDice = new List <AddDiceToPoolDice>(); noDiceIndicator.SetActive(true); availableDiceListRoot.SetActive(false); if (availableDiceListRoot.transform.childCount > 0) { int count = availableDiceListRoot.transform.childCount; for (int i = 1; i < count; ++i) { GameObject.Destroy(availableDiceListRoot.transform.GetChild(i).gameObject); } } else { Debug.LogError("No templace available dice!"); } // Setup buttons cancelButton.onClick.RemoveAllListeners(); cancelButton.onClick.AddListener(() => { central.StopScanForDice(); Hide(); }); addSelectedButton.onClick.RemoveAllListeners(); addSelectedButton.onClick.AddListener(() => { central.StopScanForDice(); if (selectedDice.Count > 0) { // Have central connect to selected dice central.ConnectToDiceList(selectedDice); } Hide(); }); // Kickoff a scan right away! central.BeginScanForDice(AddAvailableDice); }