Beispiel #1
0
        public void OnGUI(Rect rect)
        {
            Rect rect2;
            Rect rect3;

            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            using (new EditorGUI.DisabledScope(this.m_Controller == null))
            {
                AudioMixerDrawUtils.DrawRegionBg(rect, out rect2, out rect3);
                AudioMixerDrawUtils.HeaderLabel(rect2, s_Styles.header, s_Styles.viewsIcon);
            }
            if (this.m_Controller != null)
            {
                if (this.m_ReorderableListWithRenameAndScrollView.list.index != this.m_Controller.currentViewIndex)
                {
                    this.m_ReorderableListWithRenameAndScrollView.list.index = this.m_Controller.currentViewIndex;
                    this.m_ReorderableListWithRenameAndScrollView.FrameItem(this.m_Controller.currentViewIndex);
                }
                this.m_ReorderableListWithRenameAndScrollView.OnGUI(rect3);
                if (GUI.Button(new Rect(rect2.xMax - 15f, rect2.y + 3f, 15f, 15f), s_Styles.addButton, EditorStyles.label))
                {
                    this.Add();
                }
            }
        }
Beispiel #2
0
        public void OnGUI(Rect rect)
        {
            int controlId = GUIUtility.GetControlID(FocusType.Keyboard);

            if (AudioMixersTreeView.s_Styles == null)
            {
                AudioMixersTreeView.s_Styles = new AudioMixersTreeView.Styles();
            }
            this.m_TreeView.OnEvent();
            Rect headerRect;
            Rect contentRect;

            AudioMixerDrawUtils.DrawRegionBg(rect, out headerRect, out contentRect);
            AudioMixerDrawUtils.HeaderLabel(headerRect, AudioMixersTreeView.s_Styles.header, AudioMixersTreeView.s_Styles.audioMixerIcon);
            if (GUI.Button(new Rect(headerRect.xMax - 15f, headerRect.y + 3f, 15f, 15f), AudioMixersTreeView.s_Styles.addText, EditorStyles.label))
            {
                (this.m_TreeView.gui as AudioMixersTreeViewGUI).BeginCreateNewMixer();
            }
            this.m_TreeView.OnGUI(contentRect, controlId);
            if (this.m_TreeView.data.rowCount == 0)
            {
                EditorGUI.BeginDisabledGroup(true);
                GUI.Label(new RectOffset(-20, 0, -2, 0).Add(contentRect), "No mixers found");
                EditorGUI.EndDisabledGroup();
            }
            AudioMixerDrawUtils.DrawScrollDropShadow(contentRect, this.m_TreeView.state.scrollPos.y, this.m_TreeView.gui.GetTotalSize().y);
            this.HandleCommandEvents(controlId);
            this.HandleObjectSelectorResult();
        }
        public void OnGUI(Rect rect)
        {
            int controlID = GUIUtility.GetControlID(FocusType.Keyboard);

            this.m_ScrollToItem = null;
            if (AudioMixerGroupTreeView.s_Styles == null)
            {
                AudioMixerGroupTreeView.s_Styles = new AudioMixerGroupTreeView.Styles();
            }
            this.m_AudioGroupTree.OnEvent();
            Rect r;
            Rect rect2;

            using (new EditorGUI.DisabledScope(this.m_Controller == null))
            {
                AudioMixerDrawUtils.DrawRegionBg(rect, out r, out rect2);
                AudioMixerDrawUtils.HeaderLabel(r, AudioMixerGroupTreeView.s_Styles.header, AudioMixerGroupTreeView.s_Styles.audioMixerGroupIcon);
            }
            if (this.m_Controller != null)
            {
                AudioMixerGroupController parent = (this.m_Controller.CachedSelection.Count != 1) ? this.m_Controller.masterGroup : this.m_Controller.CachedSelection[0];
                using (new EditorGUI.DisabledScope(EditorApplication.isPlaying))
                {
                    if (GUI.Button(new Rect(r.xMax - 15f, r.y + 3f, 15f, 15f), AudioMixerGroupTreeView.s_Styles.addText, EditorStyles.label))
                    {
                        this.AddAudioMixerGroup(parent);
                    }
                }
                this.m_AudioGroupTree.OnGUI(rect2, controlID);
                AudioMixerDrawUtils.DrawScrollDropShadow(rect2, this.m_AudioGroupTree.state.scrollPos.y, this.m_AudioGroupTree.gui.GetTotalSize().y);
                this.HandleKeyboardEvents(controlID);
                this.HandleCommandEvents(controlID);
            }
        }
Beispiel #4
0
        public void OnGUI(Rect rect)
        {
            if (AudioMixerSnapshotListView.s_Styles == null)
            {
                AudioMixerSnapshotListView.s_Styles = new AudioMixerSnapshotListView.Styles();
            }
            Rect r;
            Rect rect2;

            using (new EditorGUI.DisabledScope(this.m_Controller == null))
            {
                AudioMixerDrawUtils.DrawRegionBg(rect, out r, out rect2);
                AudioMixerDrawUtils.HeaderLabel(r, AudioMixerSnapshotListView.s_Styles.header, AudioMixerSnapshotListView.s_Styles.snapshotsIcon);
            }
            if (this.m_Controller != null)
            {
                int snapshotIndex = this.GetSnapshotIndex(this.m_Controller.TargetSnapshot);
                if (snapshotIndex != this.m_ReorderableListWithRenameAndScrollView.list.index)
                {
                    this.m_ReorderableListWithRenameAndScrollView.list.index = snapshotIndex;
                    this.m_ReorderableListWithRenameAndScrollView.FrameItem(snapshotIndex);
                }
                this.m_ReorderableListWithRenameAndScrollView.OnGUI(rect2);
                if (GUI.Button(new Rect(r.xMax - 15f, r.y + 3f, 15f, 15f), AudioMixerSnapshotListView.s_Styles.addButton, EditorStyles.label))
                {
                    this.Add();
                }
            }
        }
 public static void DrawFilledCurve(Rect r, AudioCurveAndColorEvaluator eval)
 {
     if (Event.current.type == EventType.Repaint)
     {
         Color color;
         HandleUtility.ApplyWireMaterial();
         GL.Begin(1);
         float pixelsPerPoint = EditorGUIUtility.pixelsPerPoint;
         float num2           = 1f / pixelsPerPoint;
         float num3           = 0.5f * num2;
         float num4           = Mathf.Ceil(r.width) * pixelsPerPoint;
         float num5           = Mathf.Floor(r.x) + pixelEpsilon;
         float num6           = 1f / (num4 - 1f);
         float max            = r.height * 0.5f;
         float num8           = r.y + (0.5f * r.height);
         float y = r.y + r.height;
         float b = Mathf.Clamp(max * eval(0f, out color), -max, max);
         for (int i = 0; i < num4; i++)
         {
             float x     = num5 + (i * num2);
             float a     = Mathf.Clamp(max * eval(i * num6, out color), -max, max);
             float num14 = Mathf.Min(a, b) - num3;
             float num15 = Mathf.Max(a, b) + num3;
             GL.Color(new Color(color.r, color.g, color.b, 0f));
             AudioMixerDrawUtils.Vertex(x, num8 - num15);
             GL.Color(color);
             AudioMixerDrawUtils.Vertex(x, num8 - num14);
             AudioMixerDrawUtils.Vertex(x, num8 - num14);
             AudioMixerDrawUtils.Vertex(x, y);
             b = a;
         }
         GL.End();
     }
 }
Beispiel #6
0
        public void OnGUI(Rect rect)
        {
            if (AudioMixerGroupViewList.s_Styles == null)
            {
                AudioMixerGroupViewList.s_Styles = new AudioMixerGroupViewList.Styles();
            }
            EditorGUI.BeginDisabledGroup(this.m_Controller == null);
            Rect r;
            Rect rect2;

            AudioMixerDrawUtils.DrawRegionBg(rect, out r, out rect2);
            AudioMixerDrawUtils.HeaderLabel(r, AudioMixerGroupViewList.s_Styles.header, AudioMixerGroupViewList.s_Styles.viewsIcon);
            EditorGUI.EndDisabledGroup();
            if (this.m_Controller != null)
            {
                if (this.m_ReorderableListWithRenameAndScrollView.list.index != this.m_Controller.currentViewIndex)
                {
                    this.m_ReorderableListWithRenameAndScrollView.list.index = this.m_Controller.currentViewIndex;
                    this.m_ReorderableListWithRenameAndScrollView.FrameItem(this.m_Controller.currentViewIndex);
                }
                this.m_ReorderableListWithRenameAndScrollView.OnGUI(rect2);
                if (GUI.Button(new Rect(r.xMax - 15f, r.y + 3f, 15f, 15f), AudioMixerGroupViewList.s_Styles.addButton, EditorStyles.label))
                {
                    this.Add();
                }
            }
        }
        public void OnGUI(Rect rect)
        {
            int controlID = GUIUtility.GetControlID(FocusType.Keyboard);

            if (AudioMixersTreeView.s_Styles == null)
            {
                AudioMixersTreeView.s_Styles = new AudioMixersTreeView.Styles();
            }
            this.m_TreeView.OnEvent();
            Rect r;
            Rect rect2;

            AudioMixerDrawUtils.DrawRegionBg(rect, out r, out rect2);
            AudioMixerDrawUtils.HeaderLabel(r, AudioMixersTreeView.s_Styles.header, AudioMixersTreeView.s_Styles.audioMixerIcon);
            if (GUI.Button(new Rect(r.xMax - 15f, r.y + 3f, 15f, 15f), AudioMixersTreeView.s_Styles.addText, EditorStyles.label))
            {
                AudioMixersTreeViewGUI audioMixersTreeViewGUI = this.m_TreeView.gui as AudioMixersTreeViewGUI;
                audioMixersTreeViewGUI.BeginCreateNewMixer();
            }
            this.m_TreeView.OnGUI(rect2, controlID);
            if (this.m_TreeView.data.rowCount == 0)
            {
                using (new EditorGUI.DisabledScope(true))
                {
                    GUI.Label(new RectOffset(-20, 0, -2, 0).Add(rect2), "No mixers found");
                }
            }
            AudioMixerDrawUtils.DrawScrollDropShadow(rect2, this.m_TreeView.state.scrollPos.y, this.m_TreeView.gui.GetTotalSize().y);
            this.HandleCommandEvents(controlID);
            this.HandleObjectSelectorResult();
        }
Beispiel #8
0
        public void OnGUI()
        {
            this.Init();
            if (AudioMixerWindow.s_GuiContents == null)
            {
                AudioMixerWindow.s_GuiContents = new AudioMixerWindow.GUIContents();
            }
            AudioMixerDrawUtils.InitStyles();
            this.DetectControllerChange();
            this.m_GroupViews.OnEvent();
            this.m_SnapshotListView.OnEvent();
            this.DoToolbar();
            List <AudioMixerGroupController> allGroups = !((UnityEngine.Object) this.m_Controller != (UnityEngine.Object)null) ? new List <AudioMixerGroupController>() : this.m_Controller.GetAllAudioGroupsSlow();
            Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap = this.GetEffectMap(allGroups);

            this.m_GroupTree.UseScrollView(this.m_LayoutMode == AudioMixerWindow.LayoutMode.Horizontal);
            if (this.m_LayoutMode == AudioMixerWindow.LayoutMode.Horizontal)
            {
                this.LayoutWithStripsOnTop(allGroups, effectMap);
            }
            else
            {
                this.LayoutWithStripsOnRightSideOneScrollBar(allGroups, effectMap);
            }
            if ((double)this.m_LastSize.x != (double)this.position.width || (double)this.m_LastSize.y != (double)this.position.height)
            {
                this.m_RepaintCounter = 2;
                this.m_LastSize       = new Vector2(this.position.width, this.position.height);
            }
            this.RepaintIfNeeded();
        }
Beispiel #9
0
        public void OnGUI(Rect rect)
        {
            int controlId = GUIUtility.GetControlID(FocusType.Keyboard);

            this.m_ScrollToItem = (AudioMixerGroupController)null;
            if (AudioMixerGroupTreeView.s_Styles == null)
            {
                AudioMixerGroupTreeView.s_Styles = new AudioMixerGroupTreeView.Styles();
            }
            this.m_AudioGroupTree.OnEvent();
            EditorGUI.BeginDisabledGroup((UnityEngine.Object) this.m_Controller == (UnityEngine.Object)null);
            Rect headerRect;
            Rect contentRect;

            AudioMixerDrawUtils.DrawRegionBg(rect, out headerRect, out contentRect);
            AudioMixerDrawUtils.HeaderLabel(headerRect, AudioMixerGroupTreeView.s_Styles.header, AudioMixerGroupTreeView.s_Styles.audioMixerGroupIcon);
            EditorGUI.EndDisabledGroup();
            if (!((UnityEngine.Object) this.m_Controller != (UnityEngine.Object)null))
            {
                return;
            }
            AudioMixerGroupController parent = this.m_Controller.CachedSelection.Count != 1 ? this.m_Controller.masterGroup : this.m_Controller.CachedSelection[0];

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying);
            if (GUI.Button(new Rect(headerRect.xMax - 15f, headerRect.y + 3f, 15f, 15f), AudioMixerGroupTreeView.s_Styles.addText, EditorStyles.label))
            {
                this.AddAudioMixerGroup(parent);
            }
            EditorGUI.EndDisabledGroup();
            this.m_AudioGroupTree.OnGUI(contentRect, controlId);
            AudioMixerDrawUtils.DrawScrollDropShadow(contentRect, this.m_AudioGroupTree.state.scrollPos.y, this.m_AudioGroupTree.gui.GetTotalSize().y);
            this.HandleKeyboardEvents(controlId);
            this.HandleCommandEvents(controlId);
        }
        public void OnGUI(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            Rect headerRect, contentRect;

            using (new EditorGUI.DisabledScope(m_Controller == null))
            {
                AudioMixerDrawUtils.DrawRegionBg(rect, out headerRect, out contentRect);
                AudioMixerDrawUtils.HeaderLabel(headerRect, s_Styles.header, s_Styles.snapshotsIcon);
            }

            if (m_Controller != null)
            {
                // Ensure gui is in-sync with backend (TargetSnapShotIndex can be changed anytime from the backend)
                int targetIndex = GetSnapshotIndex(m_Controller.TargetSnapshot);
                if (targetIndex != m_ReorderableListWithRenameAndScrollView.list.index)
                {
                    m_ReorderableListWithRenameAndScrollView.list.index = targetIndex;
                    m_ReorderableListWithRenameAndScrollView.FrameItem(targetIndex);
                }
                m_ReorderableListWithRenameAndScrollView.OnGUI(contentRect);

                if (GUI.Button(new Rect(headerRect.xMax - 17f, headerRect.y + 3f, 16f, 16f), s_Styles.addButton, EditorStyles.iconButton))
                {
                    Add();
                }
            }
        }
        public void OnGUI(Rect rect)
        {
            Rect rect2;
            Rect rect3;

            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            EditorGUI.BeginDisabledGroup(this.m_Controller == null);
            AudioMixerDrawUtils.DrawRegionBg(rect, out rect2, out rect3);
            AudioMixerDrawUtils.HeaderLabel(rect2, s_Styles.header, s_Styles.snapshotsIcon);
            EditorGUI.EndDisabledGroup();
            if (this.m_Controller != null)
            {
                int snapshotIndex = this.GetSnapshotIndex(this.m_Controller.TargetSnapshot);
                if (snapshotIndex != this.m_ReorderableListWithRenameAndScrollView.list.index)
                {
                    this.m_ReorderableListWithRenameAndScrollView.list.index = snapshotIndex;
                    this.m_ReorderableListWithRenameAndScrollView.FrameItem(snapshotIndex);
                }
                this.m_ReorderableListWithRenameAndScrollView.OnGUI(rect3);
                if (GUI.Button(new Rect(rect2.xMax - 15f, rect2.y + 3f, 15f, 15f), s_Styles.addButton, EditorStyles.label))
                {
                    this.Add();
                }
            }
        }
Beispiel #12
0
        public void OnGUI(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            Rect headerRect, contentRect;

            using (new EditorGUI.DisabledScope(m_Controller == null))
            {
                AudioMixerDrawUtils.DrawRegionBg(rect, out headerRect, out contentRect);
                AudioMixerDrawUtils.HeaderLabel(headerRect, s_Styles.header, s_Styles.viewsIcon);
            }

            if (m_Controller != null)
            {
                // Ensure in-sync
                if (m_ReorderableListWithRenameAndScrollView.list.index != m_Controller.currentViewIndex)
                {
                    m_ReorderableListWithRenameAndScrollView.list.index = m_Controller.currentViewIndex;
                    m_ReorderableListWithRenameAndScrollView.FrameItem(m_Controller.currentViewIndex);
                }

                m_ReorderableListWithRenameAndScrollView.OnGUI(contentRect);

                // Call after list to prevent id mismatch
                if (GUI.Button(new Rect(headerRect.xMax - 15f, headerRect.y + 3f, 15f, 15f), s_Styles.addButton, EditorStyles.label))
                {
                    Add();
                }
            }
        }
Beispiel #13
0
 public static void DrawFilledCurve(Rect r, AudioCurveAndColorEvaluator eval)
 {
     if (Event.current.type == EventType.Repaint)
     {
         Color color;
         HandleUtility.ApplyWireMaterial();
         GL.Begin(1);
         float pixelsPerPoint = EditorGUIUtility.pixelsPerPoint;
         float num2           = 1f / pixelsPerPoint;
         float num3           = r.width * pixelsPerPoint;
         float num4           = 1f / (num3 - 1f);
         float max            = r.height * 0.5f;
         float num6           = r.y + (0.5f * r.height);
         float y    = r.y + r.height;
         float num8 = Mathf.Clamp(max * eval(0f, out color), -max, max);
         for (int i = 0; i < num3; i++)
         {
             float x     = Mathf.Floor(r.x) + (i * num2);
             float num11 = Mathf.Clamp(max * eval(i * num4, out color), -max, max);
             float num12 = ((num11 >= num8) ? num8 : num11) - (0.5f * num2);
             float num13 = ((num11 <= num8) ? num8 : num11) + (0.5f * num2);
             GL.Color(new Color(color.r, color.g, color.b, 0f));
             AudioMixerDrawUtils.Vertex(x, num6 - num13);
             GL.Color(color);
             AudioMixerDrawUtils.Vertex(x, num6 - num12);
             AudioMixerDrawUtils.Vertex(x, num6 - num12);
             AudioMixerDrawUtils.Vertex(x, y);
             num8 = num11;
         }
         GL.End();
     }
 }
        public void OnGUI(Rect rect)
        {
            if (AudioMixerSnapshotListView.s_Styles == null)
            {
                AudioMixerSnapshotListView.s_Styles = new AudioMixerSnapshotListView.Styles();
            }
            EditorGUI.BeginDisabledGroup((UnityEngine.Object) this.m_Controller == (UnityEngine.Object)null);
            Rect headerRect;
            Rect contentRect;

            AudioMixerDrawUtils.DrawRegionBg(rect, out headerRect, out contentRect);
            AudioMixerDrawUtils.HeaderLabel(headerRect, AudioMixerSnapshotListView.s_Styles.header, AudioMixerSnapshotListView.s_Styles.snapshotsIcon);
            EditorGUI.EndDisabledGroup();
            if (!((UnityEngine.Object) this.m_Controller != (UnityEngine.Object)null))
            {
                return;
            }
            int snapshotIndex = this.GetSnapshotIndex(this.m_Controller.TargetSnapshot);

            if (snapshotIndex != this.m_ReorderableListWithRenameAndScrollView.list.index)
            {
                this.m_ReorderableListWithRenameAndScrollView.list.index = snapshotIndex;
                this.m_ReorderableListWithRenameAndScrollView.FrameItem(snapshotIndex);
            }
            this.m_ReorderableListWithRenameAndScrollView.OnGUI(contentRect);
            if (!GUI.Button(new Rect(headerRect.xMax - 15f, headerRect.y + 3f, 15f, 15f), AudioMixerSnapshotListView.s_Styles.addButton, EditorStyles.label))
            {
                return;
            }
            this.Add();
        }
Beispiel #15
0
        protected static void DrawVU(Rect r, float level, float blend, bool topdown)
        {
            level = 1f - level;
            Rect rect = new Rect(r.x + 1f, (float)((double)r.y + 1.0 + (!topdown ? (double)level * (double)r.height : 0.0)), r.width - 2f, (float)((double)r.y - 2.0 + (!topdown ? (double)r.height - (double)level * (double)r.height : (double)level * (double)r.height)));

            AudioMixerDrawUtils.DrawRect(r, new Color(0.1f, 0.1f, 0.1f));
            AudioMixerDrawUtils.DrawRect(rect, new Color(0.6f, 0.2f, 0.2f));
        }
Beispiel #16
0
 public static void InitStyles()
 {
     if (AudioMixerDrawUtils.s_Styles == null)
     {
         AudioMixerDrawUtils.s_Styles = new AudioMixerDrawUtils.Styles();
         AudioMixerDrawUtils.DetectVertexOffset();
     }
 }
Beispiel #17
0
        protected static void DrawVU(Rect r, float level, float blend, bool topdown)
        {
            level = 1f - level;
            Rect rect = new Rect(r.x + 1f, r.y + 1f + ((!topdown) ? (level * r.height) : 0f), r.width - 2f, r.y - 2f + ((!topdown) ? (r.height - level * r.height) : (level * r.height)));

            AudioMixerDrawUtils.DrawRect(r, new Color(0.1f, 0.1f, 0.1f));
            AudioMixerDrawUtils.DrawRect(rect, new Color(0.6f, 0.2f, 0.2f));
        }
            // Called once per OnGUI
            public void HandleDragging(Rect totalRect, AudioMixerGroupController group, AudioMixerController controller)
            {
                // Early out if we are not dragging
                if (!isDragging)
                {
                    return;
                }

                Event       evt        = Event.current;
                const float kMoveRange = 15;

                switch (evt.GetTypeForControl(m_DragControlID))
                {
                case EventType.MouseDrag:
                    m_MovingPos = evt.mousePosition.y;
                    evt.Use();
                    break;

                case EventType.MouseUp:
                    evt.Use();
                    if (m_MovingSrcIndex != -1)
                    {
                        if (m_MovingDstIndex != -1 && m_MovingEffectAllowed)
                        {
                            var effects = group.effects.ToList();
                            if (AudioMixerController.MoveEffect(ref effects, m_MovingSrcIndex, ref effects, m_MovingDstIndex))
                            {
                                group.effects = effects.ToArray();
                            }
                        }
                        m_MovingSrcIndex = -1;
                        m_MovingDstIndex = -1;
                        controller.m_HighlightEffectIndex = -1;
                        if (GUIUtility.hotControl == m_DragControlID)
                        {
                            GUIUtility.hotControl = 0;
                        }
                        EditorGUIUtility.SetWantsMouseJumping(0);
                        AudioMixerUtility.RepaintAudioMixerAndInspectors();
                        EditorGUIUtility.ExitGUI();     // Exit because we changed order of effects
                    }
                    break;

                case EventType.Repaint:
                    if (m_DragHighlightPos > 0.0f)
                    {
                        float w               = totalRect.width;
                        Color moveColorLo     = (m_MovingEffectAllowed) ? kMoveColorLoAllowed : kMoveColorLoDisallowed;
                        Color moveColorHi     = (m_MovingEffectAllowed) ? kMoveColorHiAllowed : kMoveColorHiDisallowed;
                        Color moveColorBorder = (m_MovingEffectAllowed) ? kMoveColorBorderAllowed : kMoveColorBorderDisallowed;
                        AudioMixerDrawUtils.DrawGradientRect(new Rect(m_MovingRect.x, m_DragHighlightPos - kMoveRange, w, kMoveRange), moveColorLo, moveColorHi);
                        AudioMixerDrawUtils.DrawGradientRect(new Rect(m_MovingRect.x, m_DragHighlightPos, w, kMoveRange), moveColorHi, moveColorLo);
                        AudioMixerDrawUtils.DrawGradientRect(new Rect(m_MovingRect.x, m_DragHighlightPos - m_DragHighlightHeight / 2, w, m_DragHighlightHeight), moveColorBorder, moveColorBorder);
                    }
                    break;
                }
            }
 public override void OnInspectorGUI()
 {
     AudioMixerDrawUtils.InitStyles();
     if (this.m_EffectView == null)
     {
         this.m_EffectView = new AudioMixerEffectView();
     }
     this.m_EffectView.OnGUI(this.target as AudioMixerGroupController);
 }
        protected static void DrawVU(Rect r, float level, float blend, bool topdown)
        {
            level = 1.0f - level;
            const float border = 1;
            var         r2     = new Rect(r.x + border, r.y + border + (topdown ? 0.0f : level * r.height), r.width - 2 * border, r.y - 2 * border + (topdown ? level * r.height : r.height - level * r.height));

            AudioMixerDrawUtils.DrawRect(r, new Color(0.1f, 0.1f, 0.1f));
            AudioMixerDrawUtils.DrawRect(r2, new Color(0.6f, 0.2f, 0.2f));
        }
 public void HandleDragging(Rect totalRect, AudioMixerGroupController group, AudioMixerController controller)
 {
     if (this.isDragging)
     {
         Event     current        = Event.current;
         EventType typeForControl = current.GetTypeForControl(this.m_DragControlID);
         if (typeForControl != EventType.MouseDrag)
         {
             if (typeForControl != EventType.MouseUp)
             {
                 if (typeForControl == EventType.Repaint)
                 {
                     if (this.m_DragHighlightPos > 0f)
                     {
                         float width  = totalRect.width;
                         Color color  = (!this.m_MovingEffectAllowed) ? this.kMoveColorLoDisallowed : this.kMoveColorLoAllowed;
                         Color color2 = (!this.m_MovingEffectAllowed) ? this.kMoveColorHiDisallowed : this.kMoveColorHiAllowed;
                         Color color3 = (!this.m_MovingEffectAllowed) ? this.kMoveColorBorderDisallowed : this.kMoveColorBorderAllowed;
                         AudioMixerDrawUtils.DrawGradientRect(new Rect(this.m_MovingRect.x, this.m_DragHighlightPos - 15f, width, 15f), color, color2);
                         AudioMixerDrawUtils.DrawGradientRect(new Rect(this.m_MovingRect.x, this.m_DragHighlightPos, width, 15f), color2, color);
                         AudioMixerDrawUtils.DrawGradientRect(new Rect(this.m_MovingRect.x, this.m_DragHighlightPos - this.m_DragHighlightHeight / 2f, width, this.m_DragHighlightHeight), color3, color3);
                     }
                 }
             }
             else
             {
                 current.Use();
                 if (this.m_MovingSrcIndex != -1)
                 {
                     if (this.m_MovingDstIndex != -1 && this.m_MovingEffectAllowed)
                     {
                         List <AudioMixerEffectController> list = group.effects.ToList <AudioMixerEffectController>();
                         if (AudioMixerController.MoveEffect(ref list, this.m_MovingSrcIndex, ref list, this.m_MovingDstIndex))
                         {
                             group.effects = list.ToArray();
                         }
                     }
                     this.m_MovingSrcIndex             = -1;
                     this.m_MovingDstIndex             = -1;
                     controller.m_HighlightEffectIndex = -1;
                     if (GUIUtility.hotControl == this.m_DragControlID)
                     {
                         GUIUtility.hotControl = 0;
                     }
                     EditorGUIUtility.SetWantsMouseJumping(0);
                     AudioMixerUtility.RepaintAudioMixerAndInspectors();
                     GUIUtility.ExitGUI();
                 }
             }
         }
         else
         {
             this.m_MovingPos = current.mousePosition.y;
             current.Use();
         }
     }
 }
            public void HandleDragging(Rect totalRect, AudioMixerGroupController group, AudioMixerController controller)
            {
                if (!this.isDragging)
                {
                    return;
                }
                Event     current        = Event.current;
                EventType typeForControl = current.GetTypeForControl(this.m_DragControlID);

                switch (typeForControl)
                {
                case EventType.MouseUp:
                    current.Use();
                    if (this.m_MovingSrcIndex == -1)
                    {
                        break;
                    }
                    if (this.m_MovingDstIndex != -1 && this.m_MovingEffectAllowed)
                    {
                        List <AudioMixerEffectController> list = ((IEnumerable <AudioMixerEffectController>)group.effects).ToList <AudioMixerEffectController>();
                        if (AudioMixerController.MoveEffect(ref list, this.m_MovingSrcIndex, ref list, this.m_MovingDstIndex))
                        {
                            group.effects = list.ToArray();
                        }
                    }
                    this.m_MovingSrcIndex             = -1;
                    this.m_MovingDstIndex             = -1;
                    controller.m_HighlightEffectIndex = -1;
                    if (GUIUtility.hotControl == this.m_DragControlID)
                    {
                        GUIUtility.hotControl = 0;
                    }
                    EditorGUIUtility.SetWantsMouseJumping(0);
                    AudioMixerUtility.RepaintAudioMixerAndInspectors();
                    GUIUtility.ExitGUI();
                    break;

                case EventType.MouseDrag:
                    this.m_MovingPos = current.mousePosition.y;
                    current.Use();
                    break;

                default:
                    if (typeForControl != EventType.Repaint || (double)this.m_DragHighlightPos <= 0.0)
                    {
                        break;
                    }
                    float width  = totalRect.width;
                    Color color1 = !this.m_MovingEffectAllowed ? this.kMoveColorLoDisallowed : this.kMoveColorLoAllowed;
                    Color color2 = !this.m_MovingEffectAllowed ? this.kMoveColorHiDisallowed : this.kMoveColorHiAllowed;
                    Color color3 = !this.m_MovingEffectAllowed ? this.kMoveColorBorderDisallowed : this.kMoveColorBorderAllowed;
                    AudioMixerDrawUtils.DrawGradientRect(new Rect(this.m_MovingRect.x, this.m_DragHighlightPos - 15f, width, 15f), color1, color2);
                    AudioMixerDrawUtils.DrawGradientRect(new Rect(this.m_MovingRect.x, this.m_DragHighlightPos, width, 15f), color2, color1);
                    AudioMixerDrawUtils.DrawGradientRect(new Rect(this.m_MovingRect.x, this.m_DragHighlightPos - this.m_DragHighlightHeight / 2f, width, this.m_DragHighlightHeight), color3, color3);
                    break;
                }
            }
        public static void DrawMinMaxFilledCurve(Rect r, AudioCurveRendering.AudioMinMaxCurveAndColorEvaluator eval)
        {
            HandleUtility.ApplyWireMaterial();
            GL.Begin(1);
            float num  = EditorGUIUtility.pixelsPerPoint;
            float num2 = 1f / num;
            float num3 = 0.5f * num2;
            float num4 = Mathf.Ceil(r.width) * num;
            float num5 = Mathf.Floor(r.x) + AudioCurveRendering.pixelEpsilon;
            float num6 = 1f / (num4 - 1f);
            float num7 = r.height * 0.5f;
            float num8 = r.y + 0.5f * r.height;
            Color c;
            float value;
            float value2;

            eval(0.0001f, out c, out value, out value2);
            AudioCurveRendering.Sort2(ref value, ref value2);
            float b    = num8 - num7 * Mathf.Clamp(value2, -1f, 1f);
            float b2   = num8 - num7 * Mathf.Clamp(value, -1f, 1f);
            float y    = r.y;
            float max  = r.y + r.height;
            int   num9 = 0;

            while ((float)num9 < num4)
            {
                float x = num5 + (float)num9 * num2;
                eval((float)num9 * num6, out c, out value, out value2);
                AudioCurveRendering.Sort2(ref value, ref value2);
                Color c2    = new Color(c.r, c.g, c.b, 0f);
                float num10 = num8 - num7 * Mathf.Clamp(value2, -1f, 1f);
                float num11 = num8 - num7 * Mathf.Clamp(value, -1f, 1f);
                float y2    = Mathf.Clamp(Mathf.Min(num10, b) - num3, y, max);
                float y3    = Mathf.Clamp(Mathf.Max(num10, b) + num3, y, max);
                float y4    = Mathf.Clamp(Mathf.Min(num11, b2) - num3, y, max);
                float y5    = Mathf.Clamp(Mathf.Max(num11, b2) + num3, y, max);
                AudioCurveRendering.Sort2(ref y2, ref y4);
                AudioCurveRendering.Sort2(ref y3, ref y5);
                AudioCurveRendering.Sort2(ref y2, ref y3);
                AudioCurveRendering.Sort2(ref y4, ref y5);
                AudioCurveRendering.Sort2(ref y3, ref y4);
                GL.Color(c2);
                AudioMixerDrawUtils.Vertex(x, y2);
                GL.Color(c);
                AudioMixerDrawUtils.Vertex(x, y3);
                AudioMixerDrawUtils.Vertex(x, y3);
                AudioMixerDrawUtils.Vertex(x, y4);
                AudioMixerDrawUtils.Vertex(x, y4);
                GL.Color(c2);
                AudioMixerDrawUtils.Vertex(x, y5);
                b2 = num11;
                b  = num10;
                num9++;
            }
            GL.End();
        }
Beispiel #24
0
        public static void DrawMinMaxFilledCurve(Rect r, AudioCurveRendering.AudioMinMaxCurveAndColorEvaluator eval)
        {
            HandleUtility.ApplyWireMaterial();
            GL.Begin(1);
            float pixelsPerPoint = EditorGUIUtility.pixelsPerPoint;
            float num1           = 1f / pixelsPerPoint;
            float num2           = 0.5f * num1;
            float num3           = Mathf.Ceil(r.width) * pixelsPerPoint;
            float num4           = Mathf.Floor(r.x) + AudioCurveRendering.pixelEpsilon;
            float num5           = 1f / (num3 - 1f);
            float num6           = r.height * 0.5f;
            float num7           = r.y + 0.5f * r.height;
            Color col;
            float minValue1;
            float maxValue1;

            eval(0.0001f, out col, out minValue1, out maxValue1);
            AudioCurveRendering.Sort2(ref minValue1, ref maxValue1);
            float b1  = num7 - num6 * Mathf.Clamp(maxValue1, -1f, 1f);
            float b2  = num7 - num6 * Mathf.Clamp(minValue1, -1f, 1f);
            float y1  = r.y;
            float max = r.y + r.height;

            for (int index = 0; (double)index < (double)num3; ++index)
            {
                float x = num4 + (float)index * num1;
                eval((float)index * num5, out col, out minValue1, out maxValue1);
                AudioCurveRendering.Sort2(ref minValue1, ref maxValue1);
                Color c         = new Color(col.r, col.g, col.b, 0.0f);
                float a1        = num7 - num6 * Mathf.Clamp(maxValue1, -1f, 1f);
                float a2        = num7 - num6 * Mathf.Clamp(minValue1, -1f, 1f);
                float minValue2 = Mathf.Clamp(Mathf.Min(a1, b1) - num2, y1, max);
                float y2        = Mathf.Clamp(Mathf.Max(a1, b1) + num2, y1, max);
                float y3        = Mathf.Clamp(Mathf.Min(a2, b2) - num2, y1, max);
                float maxValue2 = Mathf.Clamp(Mathf.Max(a2, b2) + num2, y1, max);
                AudioCurveRendering.Sort2(ref minValue2, ref y3);
                AudioCurveRendering.Sort2(ref y2, ref maxValue2);
                AudioCurveRendering.Sort2(ref minValue2, ref y2);
                AudioCurveRendering.Sort2(ref y3, ref maxValue2);
                AudioCurveRendering.Sort2(ref y2, ref y3);
                GL.Color(c);
                AudioMixerDrawUtils.Vertex(x, minValue2);
                GL.Color(col);
                AudioMixerDrawUtils.Vertex(x, y2);
                AudioMixerDrawUtils.Vertex(x, y2);
                AudioMixerDrawUtils.Vertex(x, y3);
                AudioMixerDrawUtils.Vertex(x, y3);
                GL.Color(c);
                AudioMixerDrawUtils.Vertex(x, maxValue2);
                b2 = a2;
                b1 = a1;
            }
            GL.End();
        }
Beispiel #25
0
        public override void OnInspectorGUI()
        {
            AudioMixerDrawUtils.InitStyles();
            if (m_EffectView == null)
            {
                m_EffectView = new AudioMixerEffectView();
            }

            AudioMixerGroupController group = target as AudioMixerGroupController;

            m_EffectView.OnGUI(group);
        }
Beispiel #26
0
 public static void DrawLine(float x1, float y1, float x2, float y2, Color c)
 {
     if (Event.current.type == EventType.Repaint)
     {
         HandleUtility.ApplyWireMaterial();
         GL.Begin(1);
         GL.Color(new Color(c.r, c.g, c.b, c.a * AudioMixerDrawUtils.GetAlpha()));
         AudioMixerDrawUtils.Vertex(x1, y1);
         AudioMixerDrawUtils.Vertex(x2, y2);
         GL.End();
     }
 }
        public static void DrawMinMaxFilledCurve(Rect r, AudioMinMaxCurveAndColorEvaluator eval)
        {
            HandleUtility.ApplyWireMaterial();

            GL.Begin(GL.LINES);

            // Adjust by a half pixel to each side so that the transition covers a full pixel.
            // This is needed for very slowly rising edges.
            float pixelScale = (float)EditorGUIUtility.pixelsPerPoint;
            float pixelSize = 1.0f / pixelScale;
            float pixelHalfSize = 0.5f * pixelSize;
            float pixelWidth = Mathf.Ceil(r.width) * pixelScale;
            float startx = Mathf.Floor(r.x) + pixelEpsilon;
            float wx = 1.0f / (float)(pixelWidth - 1);
            float cy = r.height * 0.5f;
            float my = r.y + 0.5f * r.height;
            float minValue, maxValue;
            Color color;

            eval(0.0001f, out color, out minValue, out maxValue); Sort2(ref minValue, ref maxValue);
            float pyMax = my - cy * Mathf.Clamp(maxValue, -1.0f, 1.0f);
            float pyMin = my - cy * Mathf.Clamp(minValue, -1.0f, 1.0f);
            float y1 = r.y, y2 = r.y + r.height;

            for (int x = 0; x < pixelWidth; x++)
            {
                float nx = startx + x * pixelSize;
                eval(x * wx, out color, out minValue, out maxValue); Sort2(ref minValue, ref maxValue);
                Color edgeColor = new Color(color.r, color.g, color.b, 0.0f);
                float nyMax     = my - cy * Mathf.Clamp(maxValue, -1.0f, 1.0f);
                float nyMin     = my - cy * Mathf.Clamp(minValue, -1.0f, 1.0f);
                float a         = Mathf.Clamp(Mathf.Min(nyMax, pyMax) - pixelHalfSize, y1, y2);
                float b         = Mathf.Clamp(Mathf.Max(nyMax, pyMax) + pixelHalfSize, y1, y2);
                float c         = Mathf.Clamp(Mathf.Min(nyMin, pyMin) - pixelHalfSize, y1, y2);
                float d         = Mathf.Clamp(Mathf.Max(nyMin, pyMin) + pixelHalfSize, y1, y2);
                Sort2(ref a, ref c); Sort2(ref b, ref d); Sort2(ref a, ref b); Sort2(ref c, ref d); Sort2(ref b, ref c);
                GL.Color(edgeColor);
                AudioMixerDrawUtils.Vertex(nx, a);
                GL.Color(color);
                AudioMixerDrawUtils.Vertex(nx, b);
                AudioMixerDrawUtils.Vertex(nx, b);
                AudioMixerDrawUtils.Vertex(nx, c);
                AudioMixerDrawUtils.Vertex(nx, c);
                GL.Color(edgeColor);
                AudioMixerDrawUtils.Vertex(nx, d);
                pyMin = nyMin;
                pyMax = nyMax;
            }

            GL.End();
        }
Beispiel #28
0
        public void OnGUI()
        {
            Init();

            if (s_GuiContents == null)
            {
                s_GuiContents = new GUIContents();
            }
            AudioMixerDrawUtils.InitStyles();

            DetectControllerChange();

            m_GroupViews.OnEvent();
            m_SnapshotListView.OnEvent();

            DoToolbar();

            List <AudioMixerGroupController> allGroups;

            if (m_Controller != null)
            {
                allGroups = m_Controller.GetAllAudioGroupsSlow();
            }
            else
            {
                allGroups = new List <AudioMixerGroupController>();
            }

            var effectMap = GetEffectMap(allGroups);

            m_GroupTree.UseScrollView(m_LayoutMode == LayoutMode.Horizontal);

            if (m_LayoutMode == LayoutMode.Horizontal)
            {
                LayoutWithStripsOnTop(allGroups, effectMap);
            }
            else
            {
                LayoutWithStripsOnRightSideOneScrollBar(allGroups, effectMap);
            }

            // Ensure valid layout after maximizing window
            if (m_LastSize.x != position.width || m_LastSize.y != position.height)
            {
                m_RepaintCounter = 2;
                m_LastSize       = new Vector2(position.width, position.height);
            }

            RepaintIfNeeded();
        }
Beispiel #29
0
        public static float DoInitialModule(AudioMixerGroupController group, AudioMixerController controller, List <AudioMixerGroupController> allGroups)
        {
            Rect  rect          = EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins, new GUILayoutOption[0]);
            float valueForPitch = group.GetValueForPitch(controller, controller.TargetSnapshot);

            if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.pitch, ref valueForPitch, 100f, 1f, AudioMixerEffectView.Texts.percentage, 0.01f, 10f, controller, new AudioGroupParameterPath(group, group.GetGUIDForPitch()), new GUILayoutOption[0]))
            {
                group.SetValueForPitch(controller, controller.TargetSnapshot, valueForPitch);
            }
            GUILayout.Space(5f);
            EditorGUILayout.EndVertical();
            AudioMixerDrawUtils.DrawSplitter();
            return(rect.height);
        }
        public static void DrawFilledCurve(Rect r, AudioCurveRendering.AudioCurveAndColorEvaluator eval)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            HandleUtility.ApplyWireMaterial();
            GL.Begin(1);
            float num  = 1f / (r.width - 1f);
            float num2 = r.height * 0.5f;
            Color c;
            float num3 = r.y + Mathf.Clamp(num2 - num2 * eval(0.0001f, out c), 0f, r.height);
            int   num4 = 0;

            while ((float)num4 < r.width)
            {
                float num5 = (float)((int)r.x + num4);
                float num6 = r.y + Mathf.Clamp(num2 - num2 * eval((float)num4 * num, out c), 0f, r.height);
                GL.Color(c);
                AudioMixerDrawUtils.Vertex(num5, (float)((int)Mathf.Ceil(num6)));
                AudioMixerDrawUtils.Vertex(num5, r.y + r.height);
                if (Mathf.Abs(num3 - num6) <= 1f)
                {
                    GL.Color(new Color(c.r, c.g, c.b, c.a * (Mathf.Ceil(num6) - num6)));
                    AudioMixerDrawUtils.Vertex(num5, Mathf.Ceil(num6) - 1f);
                    AudioMixerDrawUtils.Vertex(num5, Mathf.Ceil(num6));
                }
                else
                {
                    if (num3 < num6)
                    {
                        GL.Color(new Color(c.r, c.g, c.b, 0f));
                        AudioMixerDrawUtils.Vertex(num5, Mathf.Ceil(num3));
                        GL.Color(c);
                        AudioMixerDrawUtils.Vertex(num5, Mathf.Ceil(num6));
                    }
                    else
                    {
                        GL.Color(new Color(c.r, c.g, c.b, 0f));
                        AudioMixerDrawUtils.Vertex(num5 - 1f, Mathf.Ceil(num6));
                        GL.Color(c);
                        AudioMixerDrawUtils.Vertex(num5 - 1f, Mathf.Ceil(num3));
                    }
                }
                num3 = num6;
                num4++;
            }
            GL.End();
        }