private void OpenGroupContextMenu(AudioMixerTreeViewNode audioNode, bool visible)
        {
            GenericMenu genericMenu = new GenericMenu();

            if (this.NodeWasToggled != null)
            {
                genericMenu.AddItem(new GUIContent((!visible) ? "Show Group" : "Hide group"), false, delegate
                {
                    this.NodeWasToggled(audioNode, !visible);
                });
            }
            genericMenu.AddSeparator(string.Empty);
            AudioMixerGroupController[] groups;
            if (this.m_Controller.CachedSelection.Contains(audioNode.group))
            {
                groups = this.m_Controller.CachedSelection.ToArray();
            }
            else
            {
                groups = new AudioMixerGroupController[]
                {
                    audioNode.group
                };
            }
            AudioMixerColorCodes.AddColorItemsToGenericMenu(genericMenu, groups);
            genericMenu.ShowAsContext();
        }
 public static Color GetColor(int index)
 {
     Color[] colors = AudioMixerColorCodes.GetColors();
     if (index >= 0 && index < colors.Length)
     {
         return(colors[index]);
     }
     Debug.LogError("Invalid color code index: " + index);
     return(Color.white);
 }
 public static void AddColorItemsToGenericMenu(GenericMenu menu, AudioMixerGroupController group)
 {
     Color[]  colors = AudioMixerColorCodes.GetColors();
     string[] array  = AudioMixerColorCodes.GetColorNames();
     for (int i = 0; i < colors.Length; i++)
     {
         menu.AddItem(new GUIContent(array[i]), i == group.userColorIndex, new GenericMenu.MenuFunction2(AudioMixerColorCodes.ItemCallback), new AudioMixerColorCodes.ItemData
         {
             group = group,
             index = i
         });
     }
 }
 public static void AddColorItemsToGenericMenu(GenericMenu menu, AudioMixerGroupController[] groups)
 {
     Color[]  colors     = AudioMixerColorCodes.GetColors();
     string[] colorNames = AudioMixerColorCodes.GetColorNames();
     for (int index = 0; index < colors.Length; ++index)
     {
         bool flag = groups.Length == 1 && index == groups[0].userColorIndex;
         menu.AddItem(new GUIContent(colorNames[index]), (flag ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AudioMixerColorCodes.ItemCallback), (object)new AudioMixerColorCodes.ItemData()
         {
             groups = groups,
             index  = index
         });
     }
 }
예제 #5
0
        private void OpenGroupContextMenu(AudioMixerTreeViewNode audioNode, bool visible)
        {
            GenericMenu genericMenu = new GenericMenu();

            if (this.NodeWasToggled != null)
            {
                genericMenu.AddItem(new GUIContent((!visible) ? "Show Group" : "Hide group"), false, delegate
                {
                    this.NodeWasToggled(audioNode, !visible);
                });
            }
            genericMenu.AddSeparator(string.Empty);
            AudioMixerColorCodes.AddColorItemsToGenericMenu(genericMenu, audioNode.group);
            genericMenu.ShowAsContext();
        }
예제 #6
0
        public static Color GetColor(int index)
        {
            Color[] colors = AudioMixerColorCodes.GetColors();
            Color   result;

            if (index >= 0 && index < colors.Length)
            {
                result = colors[index];
            }
            else
            {
                Debug.LogError("Invalid color code index: " + index);
                result = Color.white;
            }
            return(result);
        }
 public static void AddColorItemsToGenericMenu(GenericMenu menu, AudioMixerGroupController[] groups)
 {
     Color[]  colors = AudioMixerColorCodes.GetColors();
     string[] array  = AudioMixerColorCodes.GetColorNames();
     for (int i = 0; i < colors.Length; i++)
     {
         bool       flag     = groups.Length == 1 && i == groups[0].userColorIndex;
         GUIContent arg_73_1 = new GUIContent(array[i]);
         bool       arg_73_2 = flag;
         if (AudioMixerColorCodes.< > f__mg$cache0 == null)
         {
             AudioMixerColorCodes.< > f__mg$cache0 = new GenericMenu.MenuFunction2(AudioMixerColorCodes.ItemCallback);
         }
         menu.AddItem(arg_73_1, arg_73_2, AudioMixerColorCodes.< > f__mg$cache0, new AudioMixerColorCodes.ItemData
         {
             groups = groups,
             index  = i
         });
예제 #8
0
        public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
        {
            Event current = Event.current;

            this.DoNodeGUI(rowRect, row, node, selected, focused, false);
            if ((UnityEngine.Object) this.m_Controller == (UnityEngine.Object)null)
            {
                return;
            }
            AudioMixerTreeViewNode audioNode = node as AudioMixerTreeViewNode;

            if (audioNode == null)
            {
                return;
            }
            bool  visible        = this.m_Controller.CurrentViewContainsGroup(audioNode.group.groupID);
            float num            = 3f;
            Rect  position       = new Rect(rowRect.x + num, rowRect.y, 16f, 16f);
            Rect  rect1          = new Rect(position.x + 1f, position.y + 1f, position.width - 2f, position.height - 2f);
            int   userColorIndex = audioNode.group.userColorIndex;

            if (userColorIndex > 0)
            {
                EditorGUI.DrawRect(new Rect(rowRect.x, rect1.y, 2f, rect1.height), AudioMixerColorCodes.GetColor(userColorIndex));
            }
            EditorGUI.DrawRect(rect1, new Color(0.5f, 0.5f, 0.5f, 0.2f));
            if (visible)
            {
                GUI.DrawTexture(position, (Texture)this.k_VisibleON);
            }
            Rect rect2 = new Rect(2f, rowRect.y, rowRect.height, rowRect.height);

            if (current.type == EventType.MouseUp && current.button == 0 && (rect2.Contains(current.mousePosition) && this.NodeWasToggled != null))
            {
                this.NodeWasToggled(audioNode, !visible);
            }
            if (current.type != EventType.ContextClick || !position.Contains(current.mousePosition))
            {
                return;
            }
            this.OpenGroupContextMenu(audioNode, visible);
            current.Use();
        }
예제 #9
0
        public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused)
        {
            Event current = Event.current;
            Rect  rect    = new Rect(0f, (float)row * this.k_LineHeight + this.k_TopRowMargin, rowWidth, this.k_LineHeight);

            this.DoNodeGUI(rect, node, selected, focused, false);
            if (this.m_Controller == null)
            {
                return(rect);
            }
            AudioMixerTreeViewNode audioMixerTreeViewNode = node as AudioMixerTreeViewNode;

            if (audioMixerTreeViewNode != null)
            {
                bool  flag           = this.m_Controller.CurrentViewContainsGroup(audioMixerTreeViewNode.group.groupID);
                float num            = 3f;
                Rect  position       = new Rect(rect.x + num, rect.y, 16f, 16f);
                Rect  rect2          = new Rect(position.x + 1f, position.y + 1f, position.width - 2f, position.height - 2f);
                int   userColorIndex = audioMixerTreeViewNode.group.userColorIndex;
                if (userColorIndex > 0)
                {
                    EditorGUI.DrawRect(new Rect(rect.x, rect2.y, 2f, rect2.height), AudioMixerColorCodes.GetColor(userColorIndex));
                }
                EditorGUI.DrawRect(rect2, new Color(0.5f, 0.5f, 0.5f, 0.2f));
                if (flag)
                {
                    GUI.DrawTexture(position, this.k_VisibleON);
                }
                Rect rect3 = new Rect(2f, rect.y, rect.height, rect.height);
                if (current.type == EventType.MouseDown && current.button == 0 && rect3.Contains(current.mousePosition) && this.NodeWasToggled != null)
                {
                    this.NodeWasToggled(audioMixerTreeViewNode, !flag);
                }
                if (current.type == EventType.ContextClick && position.Contains(current.mousePosition))
                {
                    this.OpenGroupContextMenu(audioMixerTreeViewNode, flag);
                    current.Use();
                }
            }
            return(rect);
        }
예제 #10
0
        public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused)
        {
            Event current = Event.current;
            Rect  rect    = new Rect(0f, (row * base.k_LineHeight) + base.k_TopRowMargin, rowWidth, base.k_LineHeight);

            this.DoNodeGUI(rect, node, selected, focused, false);
            if (this.m_Controller != null)
            {
                AudioMixerTreeViewNode node2 = node as AudioMixerTreeViewNode;
                if (node2 == null)
                {
                    return(rect);
                }
                bool  visible        = this.m_Controller.CurrentViewContainsGroup(node2.group.groupID);
                float num2           = 3f;
                Rect  position       = new Rect(rect.x + num2, rect.y, 16f, 16f);
                Rect  rect3          = new Rect(position.x + 1f, position.y + 1f, position.width - 2f, position.height - 2f);
                int   userColorIndex = node2.group.userColorIndex;
                if (userColorIndex > 0)
                {
                    EditorGUI.DrawRect(new Rect(rect.x, rect3.y, 2f, rect3.height), AudioMixerColorCodes.GetColor(userColorIndex));
                }
                EditorGUI.DrawRect(rect3, new Color(0.5f, 0.5f, 0.5f, 0.2f));
                if (visible)
                {
                    GUI.DrawTexture(position, this.k_VisibleON);
                }
                Rect rect4 = new Rect(2f, rect.y, rect.height, rect.height);
                if (((current.type == EventType.MouseUp) && (current.button == 0)) && (rect4.Contains(current.mousePosition) && (this.NodeWasToggled != null)))
                {
                    this.NodeWasToggled(node2, !visible);
                }
                if ((current.type == EventType.ContextClick) && position.Contains(current.mousePosition))
                {
                    this.OpenGroupContextMenu(node2, visible);
                    current.Use();
                }
            }
            return(rect);
        }
        void OpenGroupContextMenu(AudioMixerTreeViewNode audioNode, bool visible)
        {
            GenericMenu menu = new GenericMenu();

            if (NodeWasToggled != null)
            {
                menu.AddItem(new GUIContent(visible ? "Hide group" : "Show Group"), false, () => NodeWasToggled(audioNode, !visible));
            }
            menu.AddSeparator(string.Empty);

            AudioMixerGroupController[] groups;
            if (m_Controller.CachedSelection.Contains(audioNode.group))
            {
                groups = m_Controller.CachedSelection.ToArray();
            }
            else
            {
                groups = new AudioMixerGroupController[] { audioNode.group }
            };

            AudioMixerColorCodes.AddColorItemsToGenericMenu(menu, groups);
            menu.ShowAsContext();
        }
예제 #12
0
        private void OpenGroupContextMenu(AudioMixerTreeViewNode audioNode, bool visible)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AudioGroupTreeViewGUI.\u003COpenGroupContextMenu\u003Ec__AnonStorey64 menuCAnonStorey64 = new AudioGroupTreeViewGUI.\u003COpenGroupContextMenu\u003Ec__AnonStorey64();
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey64.audioNode = audioNode;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey64.visible = visible;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey64.\u003C\u003Ef__this = this;
            GenericMenu menu = new GenericMenu();

            if (this.NodeWasToggled != null)
            {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated method
                menu.AddItem(new GUIContent(!menuCAnonStorey64.visible ? "Show Group" : "Hide group"), false, new GenericMenu.MenuFunction(menuCAnonStorey64.\u003C\u003Em__B2));
            }
            menu.AddSeparator(string.Empty);
            AudioMixerGroupController[] groups;
            // ISSUE: reference to a compiler-generated field
            if (this.m_Controller.CachedSelection.Contains(menuCAnonStorey64.audioNode.group))
            {
                groups = this.m_Controller.CachedSelection.ToArray();
            }
            else
            {
                // ISSUE: reference to a compiler-generated field
                groups = new AudioMixerGroupController[1]
                {
                    menuCAnonStorey64.audioNode.group
                };
            }
            AudioMixerColorCodes.AddColorItemsToGenericMenu(menu, groups);
            menu.ShowAsContext();
        }
예제 #13
0
        override public void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
        {
            Event evt = Event.current;

            DoItemGUI(rowRect, row, node, selected, focused, false);

            if (m_Controller == null)
            {
                return;
            }

            var audioNode = node as AudioMixerTreeViewNode;

            if (audioNode != null)
            {
                bool        oldSelected = m_Controller.CurrentViewContainsGroup(audioNode.group.groupID);
                const float kIconSize   = 16f;

                float xMargin    = 3f;
                Rect  iconRect   = new Rect(rowRect.x + xMargin, rowRect.y, kIconSize, kIconSize);
                Rect  iconBgRect = new Rect(iconRect.x + 1, iconRect.y + 1, iconRect.width - 2, iconRect.height - 2);

                int colorIndex = audioNode.group.userColorIndex;
                if (colorIndex > 0)
                {
                    EditorGUI.DrawRect(new Rect(rowRect.x, iconBgRect.y, 2, iconBgRect.height), AudioMixerColorCodes.GetColor(colorIndex));
                }

                if (oldSelected)
                {
                    GUI.DrawTexture(iconRect, k_VisibleON.image);
                }
                else
                {
                    GUI.DrawTexture(iconRect, k_VisibleOFF.image);
                }

                Rect toggleRect = new Rect(2, rowRect.y, rowRect.height, rowRect.height);
                if (evt.type == EventType.MouseUp && evt.button == 0 && toggleRect.Contains(evt.mousePosition))
                {
                    if (NodeWasToggled != null)
                    {
                        NodeWasToggled(audioNode, !oldSelected);
                    }
                }

                if (evt.type == EventType.ContextClick && iconRect.Contains(evt.mousePosition))
                {
                    OpenGroupContextMenu(audioNode, oldSelected);
                    evt.Use();
                }
            }
        }