Example #1
0
    private bool Show()
    {
        bool result = false;

        this.gameObject.SetActive(true);
        _selection = Wall.Instances.FirstOrDefault(w => w.Selected);

        if (_selection != null)
        {
            TowerBuildUI towerBuildUI = null;
            foreach (var prefab in _selection.Buildables)
            {
                towerBuildUI = GameObject.Instantiate <TowerBuildUI>(_towerBuildUIPrefab);
                towerBuildUI.transform.SetParent(_towerBuildUIParent.transform);
                towerBuildUI.transform.localScale = Vector3.one;
                towerBuildUI.Prefab   = prefab;
                towerBuildUI.Clicked += this.TowerBuildUIClickedHandler;
            }

            towerBuildUI = GameObject.Instantiate <TowerBuildUI>(_deleteTowerBuildUIPrefab);
            towerBuildUI.transform.SetParent(_towerBuildUIParent.transform);
            towerBuildUI.transform.localScale = Vector3.one;
            towerBuildUI.Clicked += this.TowerBuildUIClickedHandler;

            _towerBuildUIParent.UpdateSize();
            result = true;
        }

        return(result);
    }
Example #2
0
    void OnDisable()
    {
        TowerBuildUI towerBuildUI = null;

        foreach (Transform child in _towerBuildUIParent.transform)
        {
            towerBuildUI = child.GetComponent <TowerBuildUI>();
            if (towerBuildUI != null)
            {
                towerBuildUI.Clicked -= this.TowerBuildUIClickedHandler;
            }

            GameObject.Destroy(child.gameObject);
        }
    }