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; }
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); }
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))); }
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))); }
public InputMap(InputSocket source, Type connectionType, object link) { Source = source; Link = link; ConnectionType = connectionType; }
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)); }
public InputMap Connect <T> (ref InputSocket socket, out IInput <T> connection) { connection = GetOrCreateConnection <T> (socket.TargetId); return(new InputMap(socket, typeof(T), connection)); }
public InputMap(InputSocket source, Type connectionType) { ConnectionType = connectionType; ConnectionId = source.ConnectionId; }
public InputMap Connect <T>(ref InputSocket socket, ref T connection) where T : INodeInstance { return(callback.Connect(nodeInstance, ref socket, ref connection)); }