Ejemplo n.º 1
0
        public static bool EventFoldout(InAudioEventNode node, bool isSelected)
        {
            if (noMargain == null)
            {
                noMargain        = new GUIStyle();
                noMargain.margin = new RectOffset(0, 0, 0, 0);
            }

            Rect area = EditorGUILayout.BeginHorizontal();

            if (isSelected)
            {
                GUI.DrawTexture(area, EditorResources.Background);
            }

            if (node.Type != EventNodeType.Event)
            {
                GUILayout.Space(EditorGUI.indentLevel * 16);
            }
            else
            {
                GUILayout.Space(EditorGUI.indentLevel * 24);
            }
            bool folded = node.IsFoldedOut;

            if (node.Type != EventNodeType.Event)
            {
                Texture picture;
                if (folded || node.Children.Count == 0)
                {
                    picture = EditorResources.Minus;
                }
                else
                {
                    picture = EditorResources.Plus;
                }

                GUILayout.Label(picture, noMargain, GUILayout.Height(EditorResources.Minus.height), GUILayout.Width(EditorResources.Minus.width));

                Rect foldRect = GUILayoutUtility.GetLastRect();
                if (Event.current.ClickedWithin(foldRect))
                {
                    folded = !folded;
                    Event.current.Use();
                }

                TreeNodeDrawerHelper.DrawIcon(GUILayoutUtility.GetLastRect(), EditorResources.Folder, noMargain);
            }


            GUILayout.Space(30);
            EditorGUILayout.LabelField("");
            EditorGUILayout.EndHorizontal();

            Rect labelArea  = GUILayoutUtility.GetLastRect();
            Rect buttonArea = GUILayoutUtility.GetLastRect();

            if (!node.IsRoot)
            {
                buttonArea.x      = buttonArea.x + 56 + EditorGUI.indentLevel * 16;
                buttonArea.width  = 20;
                buttonArea.height = 14;
                if (node.Type != EventNodeType.Event)
                {
                    GUI.Label(buttonArea, EditorResources.Up, noMargain);
                    if (Event.current.ClickedWithin(buttonArea))
                    {
                        NodeWorker.MoveNodeOneUp(node);
                        Event.current.Use();
                    }
                    buttonArea.y += 15;
                    GUI.Label(buttonArea, EditorResources.Down, noMargain);
                    if (Event.current.ClickedWithin(buttonArea))
                    {
                        NodeWorker.MoveNodeOneDown(node);
                        Event.current.Use();
                    }
                }
                else
                {
                    buttonArea.x -= 10;
                    GUI.Label(buttonArea, EditorResources.Up, noMargain);
                    if (Event.current.ClickedWithin(buttonArea))
                    {
                        NodeWorker.MoveNodeOneUp(node);
                        Event.current.Use();
                    }
                    buttonArea.x += 15;
                    GUI.Label(buttonArea, EditorResources.Down, noMargain);
                    if (Event.current.ClickedWithin(buttonArea))
                    {
                        NodeWorker.MoveNodeOneDown(node);
                        Event.current.Use();
                    }
                }
                labelArea.x += 25;
            }
            if (node.Type != EventNodeType.Event)//As Events are smaller
            {
                labelArea.y += 6;
            }
            labelArea.x += 65;
            EditorGUI.LabelField(labelArea, node.Name);

            return(folded);
        }
Ejemplo n.º 2
0
        public static bool Draw <T>(T node, bool isSelected) where T : Object, InITreeNode <T>
        {
            if (noMargain == null)
            {
                noMargain        = new GUIStyle();
                noMargain.margin = new RectOffset(0, 0, 0, 0);
            }

            Rect area = EditorGUILayout.BeginHorizontal();

            if (isSelected)
            {
                GUI.DrawTexture(area, EditorResources.Background);
            }

            GUILayout.Space(EditorGUI.indentLevel * 16);

            bool folded = node.IsFoldedOut;

            Texture picture;

            if (folded || node.GetChildren.Count == 0)
            {
                picture = EditorResources.Minus;
            }
            else
            {
                picture = EditorResources.Plus;
            }

            GUILayout.Label(picture, noMargain, GUILayout.Height(EditorResources.Minus.height),
                            GUILayout.Width(EditorResources.Minus.width));
            Rect foldRect = GUILayoutUtility.GetLastRect();

            if (Event.current.ClickedWithin(foldRect))
            {
                folded = !folded;
                Event.current.Use();
            }
            Texture icon = TreeNodeDrawerHelper.LookUpIcon(node);


            TreeNodeDrawerHelper.DrawIcon(GUILayoutUtility.GetLastRect(), icon, noMargain);
            EditorGUILayout.LabelField("");


            EditorGUILayout.EndHorizontal();
            Rect labelArea  = GUILayoutUtility.GetLastRect();
            Rect buttonArea = labelArea;

            if (!node.IsRoot)
            {
                buttonArea.x      = buttonArea.x + 56 + EditorGUI.indentLevel * 16;
                buttonArea.width  = 20;
                buttonArea.height = 14;
                GUI.Label(buttonArea, EditorResources.Up, noMargain);
                if (Event.current.ClickedWithin(buttonArea))
                {
                    NodeWorker.MoveNodeOneUp(node);
                    Event.current.Use();
                }
                buttonArea.y += 15;
                GUI.Label(buttonArea, EditorResources.Down, noMargain);
                if (Event.current.ClickedWithin(buttonArea))
                {
                    NodeWorker.MoveNodeOneDown(node);
                    Event.current.Use();
                }
                labelArea.x += 20;
            }
            labelArea.y += 6;
            labelArea.x += 65;
            EditorGUI.LabelField(labelArea, node.GetName);

            return(folded);
        }
Ejemplo n.º 3
0
        public static bool Draw(InAudioBus node, bool isSelected)
        {
            if (noMargain == null)
            {
                noMargain        = new GUIStyle();
                noMargain.margin = new RectOffset(0, 0, 0, 0);
            }

            Rect area = EditorGUILayout.BeginHorizontal();

            if (isSelected)
            {
                GUI.DrawTexture(area, EditorResources.Background);
            }
            GUILayout.Space(EditorGUI.indentLevel * 16);
            bool folded = node.FoldedOut;

            Texture picture;

            if (folded || node.Children.Count == 0)
            {
                picture = EditorResources.Minus;
            }
            else
            {
                picture = EditorResources.Plus;
            }

            GUILayout.Label(picture, noMargain, GUILayout.Height(EditorResources.Minus.height), GUILayout.Width(EditorResources.Minus.width));
            Rect foldRect = GUILayoutUtility.GetLastRect();

            if (Event.current.ClickedWithin(foldRect))
            {
                folded = !folded;
                Event.current.Use();
            }
            EditorGUILayout.EndHorizontal();

            Rect labelArea  = GUILayoutUtility.GetLastRect();
            Rect buttonArea = labelArea;
            Rect sliderArea = buttonArea;

            buttonArea.x = buttonArea.x + 45 + EditorGUI.indentLevel * 16;
            if (!node.IsRoot)
            {
                //buttonArea.x = buttonArea.x + 45 + EditorGUI.indentLevel * 16;
                buttonArea.width  = 20;
                buttonArea.height = 14;
                GUI.Label(buttonArea, EditorResources.Up, noMargain);
                if (Event.current.ClickedWithin(buttonArea))
                {
                    NodeWorker.MoveNodeOneUp(node);
                    Event.current.Use();
                }
                buttonArea.y += 15;
                GUI.Label(buttonArea, EditorResources.Down, noMargain);
                if (Event.current.ClickedWithin(buttonArea))
                {
                    NodeWorker.MoveNodeOneDown(node);
                    Event.current.Use();
                }
                labelArea.x += 25;
            }
            else
            {
                buttonArea.y += 15;
            }

            buttonArea.height = 36;
            buttonArea.width  = 36;
            buttonArea.y     -= 18;
            buttonArea.x     -= 26;

            GUI.Label(buttonArea, EditorResources.Bus, noMargain);

            labelArea.y += 6;
            labelArea.x += 50;
            EditorGUI.LabelField(labelArea, node.Name);

            GUI.enabled       = false;
            sliderArea.y     += 6;
            sliderArea.x      = labelArea.x + 100;
            sliderArea.height = 16;
            sliderArea.width  = 180;
            if (!Application.isPlaying)
            {
                float parentVolume = 1.0f;

                if (node.Parent != null)
                {
                    parentVolume = node.Parent.CombinedVolume;

                    if (node.Parent.Mute)
                    {
                        parentVolume = 0;
                    }
                }

                node.CombinedVolume = node.Volume * node.SelfVolume * parentVolume;
                float volume = node.CombinedVolume;
                if (node.Mute)
                {
                    volume = 0;
                }
                EditorGUI.Slider(sliderArea, volume, 0.0f, 1.0f);
            }
            else
            {
                EditorGUI.Slider(sliderArea, node.FinalVolume, 0.0f, 1.0f);
            }
            GUI.enabled = true;


            return(folded);
        }