示例#1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty sourceProperty = property.FindPropertyRelative("SourceNode");

            if (sourceProperty.objectReferenceValue != null)
            {
                Rect inputNoteRect = EditorGUI.PrefixLabel(position, label);
                if (label != GUIContent.none)
                {
                    EditorGUI.LabelField(inputNoteRect, "Input", EditorStyles.centeredGreyMiniLabel);
                }
            }
            else
            {
                SerializedProperty valueProperty = property.FindPropertyRelative("defaultValue");

                if (valueProperty != null)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.PropertyField(position, valueProperty, label);
                    if (EditorGUI.EndChangeCheck())
                    {
                        InputSocket inputSocket = (InputSocket)PropertyUtility.GetTargetObjectOfProperty(property);
                        property.serializedObject.ApplyModifiedProperties();
                        inputSocket.AfterContentChanged();
                    }
                }
            }

            property.FindPropertyRelative("drawRect").rectValue = position;
        }
示例#2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var array = JArray.Load(reader);

            var inputSockets = new InputSocket[array.Count];

            for (int i = 0; i < array.Count; i++)
            {
                var arrayElement = array[i];

                var inputSource = new LocalPropertyId(arrayElement.ToObject <string>());

                if (!validOutputs.Contains(inputSource))
                {
                    Console.WriteLine($"Ignoring desired input of \"{inputSource}\" as it is not valid.");
                    return(new InputSocket[0]);
                }

                int connectionId = mappedInputs.IndexOf(inputSource);
                if (connectionId == -1)
                {
                    connectionId = mappedInputs.Count;
                    mappedInputs.Add(inputSource);
                }
                inputSockets[i] = new InputSocket(connectionId);
            }

            return(inputSockets);
        }
示例#3
0
        InputMap IGraphConnections.Connect <T> (ref InputSocket socket, ref T node)
        {
            if (socket.ConnectionId >= 0)
            {
                node = (T)nodeInstances[socket.ConnectionId];
            }

            return(new InputMap(socket, typeof(T)));
        }
示例#4
0
        InputMap IGraphConnections.Connect <T> (ref InputSocket socket, ref Input <T> input)
        {
            if (socket.ConnectionId >= 0)
            {
                var connection = GetConnection(socket.ConnectionId);

                if (connection.ConnectionType == typeof(int) &&
                    typeof(T) == typeof(float))
                {
                    var converter = new IntToFloatConverter();
                    converter.SetSource(connection);
                    connection.RegisterConverter(converter);

                    input = new Input <T> (currentNode, converter);
                }
                else
                {
                    input = new Input <T> (currentNode, connection);
                }
            }

            return(new InputMap(socket, typeof(T)));
        }
示例#5
0
 public InputMap(InputSocket source, Type connectionType, object link)
 {
     Source         = source;
     Link           = link;
     ConnectionType = connectionType;
 }
示例#6
0
 public InputMap Connect <T> (ref InputSocket socket, out T connection)
     where T : INodeInstance
 {
     connection = (T)nodeInstances[socket.TargetId];
     return(new InputMap(socket, typeof(T), connection));
 }
示例#7
0
        public InputMap Connect <T> (ref InputSocket socket, out IInput <T> connection)
        {
            connection = GetOrCreateConnection <T> (socket.TargetId);

            return(new InputMap(socket, typeof(T), connection));
        }
示例#8
0
 public InputMap(InputSocket source, Type connectionType)
 {
     ConnectionType = connectionType;
     ConnectionId   = source.ConnectionId;
 }
示例#9
0
 public InputMap Connect <T>(ref InputSocket socket, ref T connection)
     where T : INodeInstance
 {
     return(callback.Connect(nodeInstance, ref socket, ref connection));
 }