public void RefreshPanel()
    {
        //Remove all old children
        PlaceableButton[] t = panel.gameObject.GetComponentsInChildren <PlaceableButton>();
        Debug.Log("Removing " + t.Length + " old labels.");
        for (int i = t.Length - 1; i >= 0; i--)
        {
            //Destroy the extras
            Destroy(t[i].gameObject);
        }

        //Create new children
        if (allowedImmediateValues == null)
        {
            return;
        }
        foreach (string immediate in allowedImmediateValues)
        {
            GameObject g = Instantiate(PlaceableButtonPrefab) as GameObject;
            ((RectTransform)g.transform).SetParent(panel.transform);
            PlaceableButton p = g.GetComponent <PlaceableButton>();
            p.fillText = immediate;
            SetupImmediateHighlight(p.btn, new Immediate(immediate), Color.green);
        }
    }
    public void RefreshPanel()
    {
        //Remove all old children
        PlaceableButton[] t = panel.gameObject.GetComponentsInChildren <PlaceableButton>();
        Debug.Log("Removing " + t.Length + " old registers.");
        for (int i = t.Length - 1; i >= 0; i--)
        {
            //Destroy the extras
            Destroy(t[i].gameObject);
        }

        //Create new children
        if (allowedRegisters == null)
        {
            return;
        }
        foreach (Register.REGISTERS reg in allowedRegisters)
        {
            GameObject g = Instantiate(PlaceableButtonPrefab) as GameObject;
            ((RectTransform)g.transform).SetParent(panel.transform);
            PlaceableButton p = g.GetComponent <PlaceableButton>();
            p.fillText = reg.ToString();
            SetupRegisterHighlight(p.btn, reg, Color.green);
        }
    }
Ejemplo n.º 3
0
    public void SetPlaceableButtons(Level level)
    {
        foreach (Level.AvailablePlaceable placeableData in level.placeables)
        {
            PlaceableButton button = Instantiate(placeableButtonPrefab, placeableBar);
            button.transform.SetAsFirstSibling();
            button.placeablePrefab = placeableData.placeable;
            button.amount          = placeableData.amount;

            // Used instead of Awake/Start to make sure added objects are placed
            button.Setup();

            placeableButtons[placeableData.placeable.id] = button;
            totalCounter += placeableData.amount;
        }
        CheckCounter();
    }