Пример #1
0
 public void ExpandList()
 {
     expanded = true;
     for (int i = 0, len = children.Length; i < len; ++i)
     {
         UISelectMachineButton machineButton = children[i];
         children[i].gameObject.SetActive(true);
     }
 }
Пример #2
0
    void OnBind()
    {
        Vector3 groupOffset = Vector3.zero;

        MachineGroupInfo[] machineGroups = ScriptableObjects.instance.machineGroups;
        children = new UISelectMachineButton[ScriptableObjects.instance.machines.Length + 1]; // The magic number +1 is for conveyor
        int childrenIndex = 0;

        groupOffset.y += entryOffset.y;

        UISelectMachineButton conveyorButton = Instantiate(machineButtonPrefab, transform);

        conveyorButton.isConveyor = true;
        conveyorButton.transform.localPosition = groupOffset;
        conveyorButton.Initialize();
        children[childrenIndex] = conveyorButton;
        childrenIndex++;
        groupOffset.y += entryOffset.y;

        for (int i = 0, len = machineGroups.Length; i < len; ++i)
        {
            MachineGroupInfo machineGroup = machineGroups[i];
            for (int j = 0, lenJ = machineGroup.members.Length; j < lenJ; ++j)
            {
                UISelectMachineButton machineButton = Instantiate(machineButtonPrefab, transform);
                machineButton.machineInfo             = machineGroup.members[j];
                machineButton.transform.localPosition = groupOffset;
                machineButton.Initialize();
                children[childrenIndex] = machineButton;
                childrenIndex++;
                groupOffset.x += entryOffset.x;
            }
            groupOffset.x  = 0;
            groupOffset.y += entryOffset.y;
        }

        CollapseList();
    }