private int GetNodeInputFieldLinkNodeId(NodeEditorField nodeField)
                {
                    object          inputValueInstance = nodeField.GetValue();
                    INodeInputField inputField         = inputValueInstance as INodeInputField;

                    return(inputField.GetSourceNodeId());
                }
Пример #2
0
                private int GetNodeInputFieldLinkNodeId(NodeEditorField nodeField)
                {
                    object          inputValueInstance = nodeField._fieldInfo.GetValue(nodeField._nodeEditorGUI.GetEditableObject());
                    INodeInputField inputField         = inputValueInstance as INodeInputField;

                    return(inputField.GetSourceNodeId());
                }
                private void SetNodeInputFieldLinkNodeID(NodeEditorField nodeField, int nodeId)
                {
                    object          inputValueInstance = nodeField.GetValue();
                    INodeInputField inputField         = inputValueInstance as INodeInputField;

                    inputField.SetSourceNode(nodeId);
                    nodeField.SetValue(inputValueInstance);
                    nodeField._nodeEditorGUI.MarkAsDirty(true);
                }
Пример #4
0
            public static void FixupNodeRefs(NodeGraph nodeGraph, object node)
            {
                if (node != null)
                {
                    object[] nodeFieldObjects = SerializedObjectMemberInfo.GetSerializedFieldInstances(node);

                    foreach (object nodeFieldObject in nodeFieldObjects)
                    {
                        INodeInputField nodeField = nodeFieldObject as INodeInputField;

                        if (nodeField != null)
                        {
                            nodeField.SetParentNodeGraph(nodeGraph);
                        }

                        FixupNodeRefs(nodeGraph, nodeFieldObject);
                    }
                }
            }
                private void RenderStaticValueBox(NodeEditorField nodeField, Vector2 position, Color color, float scale)
                {
                    //Get _value field from the input field and then
                    object inputValueInstance = nodeField.GetValue();

                    INodeInputField inputField = inputValueInstance as INodeInputField;

                    if (inputField.IsStaticValue())
                    {
                        object nodeValue = SerializedObjectMemberInfo.GetSerializedFieldInstance(inputValueInstance, "value");

                        if (nodeValue != null)
                        {
                            string     labelText    = nodeValue + "  ";
                            GUIContent labelContent = new GUIContent(labelText);
                            Vector2    size         = _nodeBoldTextStyle.CalcSize(labelContent);
                            size.y  = kLinkIconWidth * scale;
                            size.x += kLinkIconWidth;

                            Rect staticFieldPos = new Rect(position.x - size.x, position.y - size.y * 0.5f, size.x, size.y);

                            Handles.BeginGUI();
                            Handles.color = color;
                            Handles.DrawSolidDisc(new Vector3(staticFieldPos.x + kLinkIconWidth * 0.25f, staticFieldPos.y + kLinkIconWidth * 0.5f * scale, 0.0f), -Vector3.forward, kLinkIconWidth * 0.5f * scale);
                            Handles.EndGUI();

                            Color origBackgroundColor = GUI.backgroundColor;
                            GUI.backgroundColor = color;

                            GUI.BeginGroup(staticFieldPos, EditorUtils.ColoredRoundedBoxStyle);
                            {
                                GUI.Label(new Rect(0, 0, staticFieldPos.width, staticFieldPos.height), labelContent, _nodeBoldTextStyle);
                            }
                            GUI.EndGroup();
                        }
                    }
                }