コード例 #1
0
    protected override void OnContext(AudioEvent node)
    {
        var menu = new GenericMenu();

        #region Duplicate
        if (!node.IsRoot)
        {
            menu.AddItem(new GUIContent("Duplicate"), false, data => AudioEventWorker.Duplicate(data as AudioEvent), node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent("Duplicate"));
        }
        #endregion

        menu.AddSeparator("");

        #region Create child

        if (node.Type == EventNodeType.Root)
        {
            menu.AddItem(new GUIContent(@"Create Child/Folder"), false, data => { CreateChild(node, EventNodeType.Folder); }, node);
            menu.AddItem(new GUIContent(@"Create Child/Event Group"), false, data => { CreateChild(node, EventNodeType.EventGroup); }, node);
            menu.AddDisabledItem(new GUIContent(@"Create Child/Event"));
        }
        if (node.Type == EventNodeType.Folder)
        {
            menu.AddItem(new GUIContent(@"Create Child/Folder"), false, data => { CreateChild(node, EventNodeType.Folder); }, node);
            menu.AddItem(new GUIContent(@"Create Child/Event Group"), false, data => { CreateChild(node, EventNodeType.EventGroup); }, node);
            menu.AddItem(new GUIContent(@"Create Child/Event"), false,
                         data => { CreateChild(node, EventNodeType.Event); }, node);
        }
        if (node.Type == EventNodeType.EventGroup)
        {
            menu.AddDisabledItem(new GUIContent(@"Create Child/Folder"));
            menu.AddDisabledItem(new GUIContent(@"Create Child/Event Group"));
            menu.AddItem(new GUIContent(@"Create Child/Event"), false,
                         data => { CreateChild(node, EventNodeType.Event); }, node);
        }
        if (node.Type == EventNodeType.Event)
        {
            menu.AddDisabledItem(new GUIContent(@"Create Child/Folder"));
            menu.AddDisabledItem(new GUIContent(@"Create Child/Event Group"));
            menu.AddDisabledItem(new GUIContent(@"Create Child/Event"));
        }

        #endregion

        menu.AddSeparator("");

        menu.AddItem(new GUIContent(@"Delete"), false, data => AudioEventWorker.DeleteNode(node), node);

        menu.ShowAsContext();
    }
コード例 #2
0
    protected override void OnContext(InAudioEventNode node)
    {
        var menu = new GenericMenu();

        #region Duplicate
#if !UNITY_4_1 && !UNITY_4_2
        if (!node.IsRoot)
        {
            menu.AddItem(new GUIContent("Duplicate"), false, data => AudioEventWorker.Duplicate(data as InAudioEventNode),
                         node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent("Duplicate"));
        }
        menu.AddSeparator("");
#endif
        #endregion


        #region Create child

        if (node.Type == EventNodeType.Root || node.Type == EventNodeType.Folder)
        {
            menu.AddItem(new GUIContent(@"Create Event"), false,
                         data => { CreateChild(node, EventNodeType.Event); }, node);
            menu.AddItem(new GUIContent(@"Create Folder"), false,
                         data => { CreateChild(node, EventNodeType.Folder); }, node);
        }
        if (node.Type == EventNodeType.Event)
        {
            menu.AddDisabledItem(new GUIContent(@"Create Event"));
            menu.AddDisabledItem(new GUIContent(@"Create Folder"));
        }

        #endregion

        menu.AddSeparator("");

        #region Delete
        menu.AddItem(new GUIContent(@"Delete"), false, data => {
            treeDrawer.SelectedNode = TreeWalker.GetPreviousVisibleNode(treeDrawer.SelectedNode);
            AudioEventWorker.DeleteNode(node);
        }, node);
        #endregion
        menu.ShowAsContext();
    }