예제 #1
0
 private void DrawAttributes()
 {
     GUI.color = Color.white;
     if (NodeData.GetAttributes() != null)
     {
         var i = 0;
         foreach (var attribute in NodeData.AttributesData)
         {
             EditorGUIUtility.labelWidth = 25;
             EditorGUIUtility.fieldWidth = 10;
             var attributeRect     = GetAttributeRect(i);
             var nodeAttributeRect = new Rect(NodeData.XPosition + 10, NodeData.YPosition + nodeTitleHeight, NodeData.SizeX - 20, NodeData.SizeY - nodeTitleHeight - 10);
             if (attribute.Value != null)
             {
                 var currentAttributeValue = attribute.Value.GetString();
                 attribute.Value = AttributeStyleFactory.Draw(attribute.Type, attributeRect, nodeAttributeRect, attribute.Value);
                 if (attribute.Value != null)
                 {
                     if (currentAttributeValue != attribute.Value.GetString())
                     {
                         AttributeValueChanged();
                     }
                 }
             }
             i++;
         }
     }
 }
예제 #2
0
 private void DrawAttributes()
 {
     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++;
                 }
             }
         }
     }
 }
예제 #3
0
 private void DrawParameters(ConstellationEditorStyles editorStyles)
 {
     GUI.color = Color.white;
     if (NodeData.GetParameters() != null)
     {
         var i = 0;
         foreach (var parameter in NodeData.ParametersData)
         {
             var parameterControleName = NodeData.Guid + "-" + i;
             var isFocusable           = false;
             EditorGUIUtility.labelWidth = 25;
             EditorGUIUtility.fieldWidth = 10;
             var parameterRect     = GetParameterRect(i, editorStyles);
             var nodeAttributeRect = new Rect(NodeData.XPosition + 10, NodeData.YPosition + editorStyles.nodeTitleHeight, NodeData.SizeX - 20, NodeData.SizeY - editorStyles.nodeTitleHeight - 10);
             if (parameter.Value != null)
             {
                 GUI.SetNextControlName(parameterControleName);
                 var currentParameterValue = parameter.Value.GetString();
                 parameter.Value = AttributeStyleFactory.Draw(parameter.Type, parameterRect, nodeAttributeRect, parameter.Value, editorStyles, out isFocusable);
                 if (parameter.Value != null)
                 {
                     if (currentParameterValue != parameter.Value.GetString())
                     {
                         ParameterValueChanged(i);
                     }
                 }
             }
             if (GUI.GetNameOfFocusedControl() == parameterControleName && isFocusable)
             {
                 LastFocusedAttribute = parameterControleName;
             }
             i++;
         }
     }
 }
예제 #4
0
        public NodeView(NodeData node)
        {
            isAttributeValueChanged = false;
            NodeData = node;
            nodeName = node.Name;
            LockNodeSize();
            LockNodePosition();

            foreach (var attribute in node.AttributesData)
            {
                attribute.Value = AttributeStyleFactory.Reset(attribute.Type, attribute.Value);
            }
        }
예제 #5
0
        public NodeView(NodeData _node, NodeEditorPanel _editor, NodeConfig _nodeConfig, ConstellationScript _constellation)
        {
            nodeConfig = _nodeConfig;
            var nodeWidth = nodeConfig.NodeWidth;

            if (_node.GetAttributes().Length > 0)
            {
                nodeWidth = nodeConfig.NodeWidthAsAttributes;
            }
            Rect   = new Rect(_node.XPosition, _node.YPosition, nodeWidth, (Mathf.Max(Mathf.Max(_node.Inputs.Count, _node.Outputs.Count), _node.AttributesData.Count) * nodeConfig.InputSize) + nodeConfig.TopMargin);
            node   = _node;
            editor = _editor;
            constellationScript = _constellation;

            foreach (var attribute in node.AttributesData)
            {
                attribute.Value = AttributeStyleFactory.Reset(attribute.Type, attribute.Value);
            }
        }
예제 #6
0
        public NodeView(NodeData node)
        {
            changedParameters = new List <int>();
            NodeData          = node;
            if (node.OverrideDisplayedName == "")
            {
                nodeName = node.Name;
            }
            else
            {
                nodeName = node.OverrideDisplayedName;
            }
            LockNodeSize();
            LockNodePosition();

            foreach (var attribute in node.ParametersData)
            {
                attribute.Value = AttributeStyleFactory.Reset(attribute.Type, attribute.Value);
            }
        }
예제 #7
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);
            }
        }