示例#1
0
        public void DrawHeader()
        {
            var width = Rect.width - 10;

            if (selected)
            {
                var color = GUI.color;
                width -= ButtonSize * 2 + 7;

                //Light gray color for close button
                GUI.color = new Color(0.8f, 0.8f, 0.8f);
                UnityEngine.GUI.Box(new Rect(Rect.width - (ButtonSize + 2), 1, ButtonSize, ButtonSize), "", UnityEngine.GUI.skin.GetStyle("sv_label_0"));
                if (GUI.Button(new Rect(Rect.width - (ButtonSize + 1), 1, ButtonSize - 2, ButtonSize), "", UnityEngine.GUI.skin.GetStyle("WinBtnClose")) && Event.current.button == 0)
                {
                    DestroyNode();
                }

                GUI.color = color;
                var helpPosition = new Rect(Rect.width - (ButtonSize * 2 + 5), 1, ButtonSize, ButtonSize);
                if (GUI.Button(new Rect(Rect.width - (ButtonSize * 2 + 5), 1, ButtonSize, ButtonSize), "", nodeConfig.HelpStyle) && Event.current.button == 0)
                {
                    NodeHelpWindow.ShowHelpWindow(node.Name);
                }
            }

            GUI.Label(new Rect(10, 0, width, 16), node.Name, UnityEngine.GUI.skin.GetStyle("MiniLabel"));
        }
示例#2
0
        public void DrawContent()
        {
            if (node.GetAttributes() != null)
            {
                var i = 0;
                foreach (var attribute in node.AttributesData)
                {
                    EditorGUIUtility.labelWidth = 25;
                    EditorGUIUtility.fieldWidth = 10;
                    var attributeRect = new Rect(nodeConfig.AtrributeSize.x, nodeConfig.AtrributeSize.y + (nodeConfig.AtrributeSize.height * i), nodeConfig.AtrributeSize.width, nodeConfig.AtrributeSize.height);
                    if (attribute.Value != null)
                    {
                        var currentAttributeValue = attribute.Value.GetString();
                        attribute.Value = AttributeStyleFactory.Draw(attribute.Type, attributeRect, attribute.Value);
                        if (attribute.Value != null)
                        {
                            if (currentAttributeValue != attribute.Value.GetString())
                            {
                                AttributeValueChanged();
                            }
                            i++;
                        }
                    }
                }
            }
            if (node.Inputs != null)
            {
                var i = 0;
                foreach (var input in node.Inputs)
                {
                    GUIStyle style;
                    if (input.IsWarm == true)
                    {
                        if (input.Type == "Object")
                        {
                            style = nodeConfig.WarmInputObjectStyle;
                        }
                        else
                        {
                            style = nodeConfig.WarmInputStyle;
                        }
                    }
                    else
                    {
                        if (input.Type == "Object")
                        {
                            style = nodeConfig.ColdInputObjectStyle;
                        }
                        else
                        {
                            style = nodeConfig.ColdInputStyle;
                        }
                    }

                    if (GUI.Button(new Rect(0, nodeConfig.TopMargin + (nodeConfig.InputSize * i), nodeConfig.InputSize, nodeConfig.InputSize), "",
                                   style))
                    {
                        Event current = Event.current;
                        if (current.button == 0)
                        {
                            editor.AddLinkFromInput(input);
                        }
                        else
                        {
                            DrawDescription = true;
                            Description     = input.Description;
                        }
                    }
                    i++;
                }
            }

            if (node.Outputs != null)
            {
                var i = 0;
                foreach (var output in node.Outputs)
                {
                    GUIStyle style;
                    if (output.IsWarm == true)
                    {
                        if (output.Type == "Object")
                        {
                            style = nodeConfig.WarmInputObjectStyle;
                        }
                        else
                        {
                            style = nodeConfig.WarmInputStyle;
                        }
                    }
                    else
                    {
                        if (output.Type == "Object")
                        {
                            style = nodeConfig.ColdInputObjectStyle;
                        }
                        else
                        {
                            style = nodeConfig.ColdInputStyle;
                        }
                    }
                    if (GUI.Button(new Rect(Rect.width - nodeConfig.OutputSize, nodeConfig.TopMargin + ((nodeConfig.OutputSize) * i), nodeConfig.OutputSize, nodeConfig.OutputSize), "",
                                   style))
                    {
                        Event current = Event.current;
                        if (current.button == 0)
                        {
                            editor.AddLinkFromOutput(output);
                        }
                        else
                        {
                            DrawDescription = true;
                            Description     = output.Description;
                        }
                    }
                    i++;
                }
            }

            GUI.Label(new Rect(40, 0, 100, 16), node.Name, UnityEngine.GUI.skin.GetStyle("MiniLabel"));

            UnityEngine.GUI.Box(new Rect(0, 1, 20, 13), "", UnityEngine.GUI.skin.GetStyle("sv_label_0"));
            if (GUI.Button(new Rect(4, 1, 13, 13), "", GUI.skin.GetStyle("WinBtnClose")))
            {
                DestroyNode();
            }
            if (GUI.Button(new Rect(20, 1, 20, 13), "?", UnityEngine.GUI.skin.GetStyle("sv_label_0")))
            {
                NodeHelpWindow.ShowHelpWindow(node.Name);
            }
            if (DrawDescription)
            {
                DrawHelp(Description);
            }
        }