public void Select(GameObject sel) { if (forward.ContainsKey(sel)) { //this can happen when a previously selected unit is also in the new selection box return; } HexSelectable selectable = sel.GetComponent <HexSelectable>(); Button thumb = Instantiate <Button>(_buttonPrefab); thumb.GetComponent <RectTransform>().SetParent(this.GetComponent <RectTransform>()); thumb.gameObject.SetActive(true); thumb.transform.GetChild(0).GetComponent <Text>().text = sel.name; thumb.transform.GetChild(1).GetComponent <Image>().sprite = selectable.Thumbnail; thumb.onClick.AddListener(() => { if (SelectRequested != null) { SelectRequested.Invoke(sel); } }); forward[sel] = thumb; reverse[thumb] = sel; }
/// <summary> /// Select this node in the parent tree. /// </summary> public void Select() { SelectRequested?.Invoke(this, EventArgs.Empty); }