Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
 /// <summary>
 /// Select this node in the parent tree.
 /// </summary>
 public void Select()
 {
     SelectRequested?.Invoke(this, EventArgs.Empty);
 }