Example #1
0
 private void RegisterCommands()
 {
     // bind the default commands to the buttons
     zoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
     zoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
     zoom100Button.SetCommand(Commands.Zoom, 1, graphControl);
     fitContentButton.SetCommand(Commands.FitContent, graphControl);
     undoButton.SetCommand(Commands.Undo, graphControl);
     redoButton.SetCommand(Commands.Redo, graphControl);
     GroupSelectionButton.SetCommand(Commands.GroupSelection, graphControl);
     UngroupSelectionButton.SetCommand(Commands.UngroupSelection, graphControl);
     CutButton.SetCommand(Commands.Cut, graphControl);
     copyButton.SetCommand(Commands.Copy, graphControl);
     PasteButton.SetCommand(Commands.Paste, graphControl);
     openButton.SetCommand(Commands.Open, graphControl);
     SaveButton.SetCommand(Commands.SaveAs, graphControl);
     DeleteButton.SetCommand(Commands.Delete, graphControl);
 }
    private void addGroupButton(Group group, int groupIndex)
    {
        //instantiate a prefab and add it to buttonPanel - layout manager will do the rest
        GameObject createdGroupButton = Instantiate(groupSelectionButton.gameObject) as GameObject;

        createdGroupButton.transform.SetParent(buttonPanel);
        createdGroupButton.transform.localScale = scaleEqualizer;

        GroupSelectionButton groupButtonScriptObj = createdGroupButton.GetComponent <GroupSelectionButton>();

        groupButtons.Add(groupButtonScriptObj);
        groupButtonScriptObj.Group      = group;
        groupButtonScriptObj.GroupPanel = groupPanel;
        groupButtonScriptObj.GroupIndex = groupIndex;


        groupButtonScriptObj.UpdateText();
    }
    public void RemoveGroup(GroupButton groupButton)
    {
        int groupIndex = wave.Groups.IndexOf(groupButton.Group);

        //dont let user delete the last group
        if (groupIndex == 0 && wave.Groups.Count == 1)
        {
            return;
        }

        #region substitute the currently selected group in the groupPanel(which will be deleted) by another

        GroupSelectionButton nextSelectedButton;

        //check if group with next index exists
        if (groupIndex + 1 < groupButtons.Count &&
            (nextSelectedButton = groupButtons[groupIndex + 1]) != null)
        {
            //just wait
        }
        else         //there must be a group with previous index
        {
            nextSelectedButton = groupButtons[groupIndex - 1];
        }

        groupPanel.OnSelectedGroupChange(nextSelectedButton);
        #endregion

        GroupSelectionButton btn = groupButtons[groupIndex];
        groupButtons.Remove(btn);
        Destroy(btn.gameObject);


        PauseInputField pauseBtn = pauseInputFields[groupIndex];
        pauseInputFields.Remove(pauseBtn);
        Destroy(pauseBtn.gameObject);

        wave.Groups.RemoveAt(groupIndex);
    }