public static void IssueOnAddConnection(NodeInput input) { if (OnAddConnection != null) OnAddConnection.Invoke (input); for (int cnt = 0; cnt < receiverCount; cnt++) { if (callbackReceiver [cnt] == null) callbackReceiver.RemoveAt (cnt--); else callbackReceiver [cnt].OnAddConnection (input); } }
/// <summary> /// Applies a connection between output and input. 'CanApplyConnection' has to be checked before /// </summary> public static void ApplyConnection(NodeOutput output, NodeInput input) { if (input != null && output != null) { if (input.connection != null) { input.connection.connections.Remove (input); } input.connection = output; output.connections.Add (input); NodeEditor.RecalculateFrom (input.body); } }
/// <summary> /// Applies a connection between output and input. 'CanApplyConnection' has to be checked before /// </summary> public static void ApplyConnection(NodeOutput output, NodeInput input) { if (input != null && output != null) { // 11-27-2016 @radiatoryang -- changed "only one input connection" check) if (input.connection != null && input.body.ForceOnePerInput) input.connection.connections.Remove (input); input.connection = output; output.connections.Add (input); NodeEditor.RecalculateFrom (input.body); NodeEditorCallbacks.IssueOnAddConnection (input); } }
/// <summary> /// Applies a connection between output and input. 'CanApplyConnection' has to be checked before /// </summary> public static void ApplyConnection(NodeOutput output, NodeInput input) { if (input != null && output != null) { if (input.connection != null) { input.connection.connections.Remove (input); } input.connection = output; output.connections.Add (input); if (input.body.shouldCalculate) NodeEditor.RecalculateFrom (input.body); NodeEditorCallbacks.IssueOnAddConnection (input); } }
/// <summary> /// Check if an output and an input can be connected (same type, ...) /// </summary> public static bool CanApplyConnection(NodeOutput output, NodeInput input) { if (input == null || output == null) return false; if (input.body == output.body || input.connection == output) return false; if (input.type != output.type) return false; if (output.body.isChildOf (input.body)) { NodeEditorWindow.editor.ShowNotification (new GUIContent ("Recursion detected!")); return false; } return true; }
/// <summary> /// Check if an output and an input can be connected (same type, ...) /// </summary> public static bool CanApplyConnection(NodeOutput output, NodeInput input) { if (input == null || output == null) return false; if (input.body == output.body || input.connection == output) return false; if (input.type != output.type) return false; if ((!output.body.allowRecursion || !input.body.allowRecursion) && output.body.isChildOf (input.body)) { // TODO: Generic Notification //ShowNotification (new GUIContent ("Recursion detected!")); return false; } return true; }
/// <summary> /// Check if an output and an input can be connected (same type, ...) /// </summary> public static bool CanApplyConnection(NodeOutput output, NodeInput input) { if (input == null || output == null) return false; if (input.body == output.body || input.connection == output) return false; if (input.type != output.type) return false; bool isRecursive = output.body.isChildOf (input.body); if (isRecursive) { if (!output.body.allowsLoopRecursion (input.body)) { // TODO: Generic Notification Debug.LogWarning ("Cannot apply connection: Recursion detected!"); return false; } } return true; }
private void Input_OnInputAdded(NodeInput n) { UpdateOutputType(); Updated(); }
private void Input_OnInputAdded(NodeInput n) { Updated(); }
private void OnInputAdded(NodeInput n) { TryAndProcess(); }
private void Input_OnInputRemoved(NodeInput n) { Output.Data = null; Output.Changed(); }
public PerlinAdjustNode() { output = new NodeOutput(); inputA = new NodeInput(); }
public override void OnInputConnectionRemoved(NodeInput removedInput) { //_meshOutput = null; }
/// <summary> /// Callback when the NodeInput was assigned a new connection /// </summary> protected internal virtual void OnAddInputConnection(NodeInput input) { }
public MeshNode(int w, int h, GraphPixelType p = GraphPixelType.RGBA) { Name = "Mesh"; Id = Guid.NewGuid().ToString(); width = w; height = h; tileX = tileY = 1; meshtileX = meshtileY = 1; scaleZ = scaleY = scaleX = 1; rotationX = RotationY = rotationZ = 0; xOffset = yOffset = zOffset = 0; cameraZoom = 3; previewProcessor = new BasicImageRenderer(); processor = new MeshProcessor(); internalPixelType = p; Inputs = new List <NodeInput>(); inputAlbedo = new NodeInput(NodeType.Color, this, "Albedo"); inputHeight = new NodeInput(NodeType.Gray, this, "Height"); inputMetallic = new NodeInput(NodeType.Gray, this, "Metallic"); inputRoughness = new NodeInput(NodeType.Gray, this, "Roughness"); inputOcclusion = new NodeInput(NodeType.Gray, this, "Occlusion"); inputNormal = new NodeInput(NodeType.Color, this, "Normal"); Inputs.Add(inputAlbedo); Inputs.Add(inputMetallic); Inputs.Add(inputRoughness); Inputs.Add(inputNormal); Inputs.Add(inputHeight); Inputs.Add(inputOcclusion); inputAlbedo.OnInputAdded += Input_OnInputAdded; inputAlbedo.OnInputChanged += Input_OnInputChanged; inputAlbedo.OnInputRemoved += Input_OnInputRemoved; inputNormal.OnInputAdded += Input_OnInputAdded; inputNormal.OnInputChanged += Input_OnInputChanged; inputNormal.OnInputRemoved += Input_OnInputRemoved; inputOcclusion.OnInputAdded += Input_OnInputAdded; inputOcclusion.OnInputChanged += Input_OnInputChanged; inputOcclusion.OnInputRemoved += Input_OnInputRemoved; inputRoughness.OnInputAdded += Input_OnInputAdded; inputRoughness.OnInputChanged += Input_OnInputChanged; inputRoughness.OnInputRemoved += Input_OnInputRemoved; inputMetallic.OnInputAdded += Input_OnInputAdded; inputMetallic.OnInputChanged += Input_OnInputChanged; inputMetallic.OnInputRemoved += Input_OnInputRemoved; inputHeight.OnInputAdded += Input_OnInputAdded; inputHeight.OnInputChanged += Input_OnInputChanged; inputHeight.OnInputRemoved += Input_OnInputRemoved; Output = new NodeOutput(NodeType.Gray, this); Outputs = new List <NodeOutput>(); Outputs.Add(Output); }
public DisconnectNodesCommand(NodeOutput output, NodeInput input) { m_output = output; m_input = input; }
protected void UpdateInputs() { List <NodeOutput> previousOutputs = new List <NodeOutput>(); List <int> indices = new List <int>(); List <NodeInput> previous = new List <NodeInput>(); foreach (var i in Inputs) { //isntead of directly //removing from UI at this point //we simply store them //for later when //we either replace them //or completely remove them previous.Add(i); int index = -1; previousOutputs.Add(i.Input); if (i.HasInput) { index = i.Input.To.IndexOf(i); i.Input.Remove(i); } indices.Add(index); } Inputs.Clear(); if (previousOutputs.Count > 0) { var prevEx = previousOutputs[0]; var idx = indices[0]; if (prevEx != null) { if (idx == -1) { prevEx.Add(executeInput, false); } else { prevEx.InsertAt(idx, executeInput, false); } } } Inputs.Add(executeInput); if (previous.Count > 0) { AddedInput(executeInput, previous[0]); } else { AddedInput(executeInput); } if (selectedFunction != null) { var nodes = selectedFunction.Nodes; List <Node> args = nodes.FindAll(m => m is ArgNode); int i = 1; foreach (ArgNode arg in args) { NodeInput input = new NodeInput(arg.InputType, this, arg.InputName); if (previousOutputs.Count > 1 && i < previousOutputs.Count) { var prev = previousOutputs[i]; var idx = indices[i]; //whoops forgot to verify that the output //parent could indeed accept the new input arg type if (prev != null && (prev.Type & input.Type) != 0) { if (idx < 0) { prev.Add(input, false); } else { prev.InsertAt(idx, input, false); } } } Inputs.Add(input); input.OnInputAdded += Input_OnInputAdded; input.OnInputChanged += Input_OnInputChanged; //if we still have previous nodes //then we simply want to try and //replace them on add //so the UI will update the graphical connections //otherwise we just add a new input node if (i < previous.Count) { AddedInput(input, previous[i]); } else { AddedInput(input); } i++; } //remove any left over nodes from ui //if they were not replaced //this happens in cases where //the new function set has less args //then the previous function set while (i < previous.Count) { RemovedInput(previous[i]); i++; } UpdateOutputType(); } }
private void Inp_OnInputChanged(NodeInput n) { Node_OnUpdate(n.Node); }
private void Inp_OnInputAdded(NodeInput n) { Node_OnUpdate(n.Node); }
private void Nd_OnInputRemovedFromNode(Node n, NodeInput inp) { inp.OnInputChanged -= Inp_OnInputChanged; inp.OnInputAdded -= Inp_OnInputAdded; }
private void Nd_OnInputAddedToNode(Node n, NodeInput inp) { inp.OnInputChanged += Inp_OnInputChanged; inp.OnInputAdded += Inp_OnInputAdded; }
private void DrawSelectFunction(NodeOutput outPut, NodeInput inPut) { var functions = selects[outPut].functions; var target = functions[inPut]; if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; inPut.DisplayLayout(); if (isExpanded) { if (target is SpriteChanger) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[0]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); DestroyImmediate(target, true); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); SpriteChanger changer = (SpriteChanger)target; GUILayout.BeginHorizontal(); GUILayout.Label("기본 스프라이트"); changer.baseSprite = EditorGUILayout.ObjectField (changer.baseSprite, typeof(Sprite), true) as Sprite; GUILayout.Label("선택 스프라이트"); changer.selectedSprite = EditorGUILayout.ObjectField (changer.selectedSprite, typeof(Sprite), true) as Sprite; GUILayout.EndHorizontal(); } else if (target is Enabler) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[1]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); DestroyImmediate(target, true); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); Enabler enabler = (Enabler)target; enabler.option = (EnableOption)EditorGUILayout.EnumPopup("옵션", enabler.option); } else if (target is SoundPlayer) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[2]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); DestroyImmediate(target, true); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); SoundPlayer player = (SoundPlayer)target; player.sound = EditorGUILayout.ObjectField("효과음", player.sound, typeof(AudioClip), true) as AudioClip; } else if (target is MessageDisplayer) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[3]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); DestroyImmediate(target, true); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); GUILayout.BeginHorizontal(); MessageDisplayer displayer = (MessageDisplayer)target; displayer.inputMessage = EditorGUILayout.TextArea(displayer.inputMessage); GUILayout.EndHorizontal(); } else if (target is ItemGainer) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[4]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); DestroyImmediate(target, true); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); } else if (target is DangerChanger) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[5]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); DestroyImmediate(target, true); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); DangerChanger dChanger = (DangerChanger)target; dChanger.newDanger = EditorGUILayout.IntField("새 위험도", dChanger.newDanger); } else if (target is SpriteShower) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[6]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); DestroyImmediate(target,true); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); SpriteShower shower = (SpriteShower)target; for (int i=0; i<shower.sprites.Count; i++) { shower.sprites[i] = EditorGUILayout.ObjectField(shower.sprites[i], typeof(Sprite), true) as Sprite; } Sprite newSprite = null; newSprite = EditorGUILayout.ObjectField(newSprite, typeof(Sprite), true) as Sprite; if(newSprite != null) { shower.sprites.Add(newSprite); } } else if (target is EventMaker) { GUILayout.BeginHorizontal(); GUILayout.Label(selectOptions[7]); if(GUILayout.Button("기능 삭제")) { if (!selects.ContainsKey(outPut) || !functions.ContainsKey(inPut)) return; DestroyImmediate((MonoBehaviour)functions[inPut]); functions.Remove(inPut); try { inPut.connection.connections.Remove(inPut); } catch (NullReferenceException e) { } Inputs.Remove(inPut); Vector2 topLeft = rect.position; rect = new Rect (topLeft.x, topLeft.y, 200, 100); DrawConnectors(); return; } GUILayout.EndHorizontal(); target.delay = EditorGUILayout.FloatField("발동 딜레이(초)", target.delay); GUILayout.BeginHorizontal(); EventMaker eventMaker = (EventMaker)target; eventMaker.eventFlag = EditorGUILayout.TextField("이벤트명", eventMaker.eventFlag); GUILayout.EndHorizontal(); } GUILayout.Space(10); } }
public NChangeFlowChart() { input = new NodeInput(); input.inputNode = new List <NTemplate>(); }
public object Receive(NodeInput input) { input.hasResult = false; return input.connection.value; }
public virtual void AddInput(NodeInput input) { Inputs.Add(input); }
protected override void AddPlaceholderInput() { var input = new NodeInput(NodeType.Bool, this, "Bool Input " + Inputs.Count); Inputs.Add(input); }
bool FixupForSubCanvas() { if (!string.IsNullOrEmpty(m_CanvasGuid) && m_SubCanvas == null) { string nodeCanvasPath = AssetDatabase.GUIDToAssetPath(m_CanvasGuid); m_SubCanvas = NodeEditorSaveManager.LoadNodeCanvas(nodeCanvasPath, false); m_WasCloned = false; } if (m_SubCanvas != null) { if (!m_WasCloned) { m_SubCanvas = NodeEditorSaveManager.CreateWorkingCopy(m_SubCanvas, false); //miked remove ref m_WasCloned = true; /* test its making unique nodes * foreach (Node n in m_SubCanvas.nodes) * { * if (n is TextureNode) * { * var tnIn = n as TextureNode; * var was = tnIn.m_TexHeight; * tnIn.m_TexHeight = Random.Range(1000, 1500); * Debug.Log("Change sub routines node" + tnIn + " tex height to " + tnIn.m_TexHeight + " was " + was); * * } * } */ } List <NodeInput> needsInput = new List <NodeInput>(); List <TextureNode> needsOutput = new List <TextureNode>(); foreach (Node n in m_SubCanvas.nodes) { if (n.Inputs.Count > 0) { if (n is UnityTextureOutput && n.Inputs[0].connection != null) { needsOutput.Add(n as TextureNode); } if (n is UnityTextureOutputMetalicAndRoughness && n.Inputs[0].connection != null) { needsOutput.Add(n as TextureNode); } for (int i = 0; i < n.Inputs.Count; i++) { if (n.Inputs[i].connection == null) { //this node has no input so we will wire it up to ours needsInput.Add(n.Inputs[i]); // Debug.Log(" missing input for node "+n+" name "+n.name); } } } } if (needsOutput.Count > Outputs.Count) { while (needsOutput.Count > Outputs.Count) { // Debug.Log(" create input "+Inputs.Count); string nname = GetNodeOutputName(needsOutput[Outputs.Count]); CreateOutput("Texture" + Outputs.Count + " " + nname, needsOutput[Outputs.Count].Inputs[0].connection.typeID, NodeSide.Right, 50 + Outputs.Count * 20); } } if (needsOutput.Count > 0) { Outputs[0].name = "Texture0" + " " + GetNodeOutputName(needsOutput[0]); } if (needsInput.Count > Inputs.Count) { int added = 0; for (int index = Inputs.Count; index < needsInput.Count; index++) { string needInputname = needsInput[index].name; // Debug.Log(" create input "+Inputs.Count); NodeInput newInput = CreateInput(needInputname, needsInput[index].typeID, NodeSide.Left, 30 + Inputs.Count * 20); if (newInput.typeID == "Float") { var n = Node.Create("inputNode", rect.position - new Vector2(100, 50 - added * 60)); added++; InputNode inode = n as InputNode; if (inode != null) { newInput.ApplyConnection(inode.Outputs[0], false); InputNode ip = (InputNode)n; Node nodeThatNeedsInput = needsInput[index].body; //Use reflection to find the float remap member var that matches the input FieldInfo[] myField = nodeThatNeedsInput.GetType().GetFields(); foreach (var x in myField) { // if(x.FieldType is FloatRemap) if (x.GetValue(nodeThatNeedsInput) is FloatRemap) { FloatRemap fr = (FloatRemap)x.GetValue(nodeThatNeedsInput); //its a struct this makes a copy // Debug.Log(x + " " + x.FieldType + " " + x.GetType() + " " + x.ReflectedType+" fr val:"+fr.m_Value); if (fr.m_ReplaceWithInput && fr.m_Replacement == null) { Debug.LogError(" wants to be replaced but isnt linked "); } else if (fr.m_Replacement != null) { NodeKnob knob = fr.m_Replacement; NodeInput replace = knob as NodeInput; if (replace != null) { if (replace == needsInput[index]) { ip.m_Value.Set(fr.m_Value); ip.m_Value.m_Min = fr.m_Min; ip.m_Value.m_Max = fr.m_Max; } } } } } } } } m_InputsCreated = true; //CreateNewFloatInputs(); return(false); } } return(true); }
public override void TryAndProcess() { NodeInput input = Inputs[1]; NodeInput input2 = Inputs[2]; if (!input.IsValid || !input2.IsValid) { return; } NodeType t1 = input.Reference.Type; NodeType t2 = input2.Reference.Type; try { if (t1 == NodeType.Float && t2 == NodeType.Float) { float v1 = input.Data.ToFloat(); float v2 = input2.Data.ToFloat(); output.Data = v1 * v2; } else if ((t1 == NodeType.Float2 || t1 == NodeType.Float3 || t1 == NodeType.Float4) && (t2 == NodeType.Float2 || t2 == NodeType.Float3 || t2 == NodeType.Float4)) { MVector v1 = (MVector)input.Data; MVector v2 = (MVector)input2.Data; output.Data = v1 * v2; } else if (t1 == NodeType.Float && (t2 == NodeType.Float2 || t2 == NodeType.Float3 || t2 == NodeType.Float4)) { float v1 = Utils.ConvertToFloat(input.Data); MVector v2 = (MVector)input2.Data; output.Data = v1 * v2; } else if ((t1 == NodeType.Float2 || t1 == NodeType.Float3 || t1 == NodeType.Float4) && t2 == NodeType.Float) { float v2 = Utils.ConvertToFloat(input2.Data); MVector v1 = (MVector)input.Data; output.Data = v1 * v2; } else if ((t1 == NodeType.Float2 || t1 == NodeType.Float3 || t1 == NodeType.Float4) && t2 == NodeType.Matrix) { MVector v1 = (MVector)input.Data; Vector4 vec = new Vector4(v1.X, v1.Y, v1.Z, v1.W); if (t1 == NodeType.Float2 || t1 == NodeType.Float3) { vec.W = 1; } Matrix4 m = (Matrix4)input2.Data; output.Data = m * vec; } else if (t1 == NodeType.Matrix && (t2 == NodeType.Float2 || t2 == NodeType.Float3 || t2 == NodeType.Float4)) { MVector v1 = (MVector)input2.Data; Vector4 vec = new Vector4(v1.X, v1.Y, v1.Z, v1.W); Matrix4 m = (Matrix4)input.Data; if (t2 == NodeType.Float2 || t2 == NodeType.Float3) { vec.W = 1; } output.Data = vec * m; } result = output.Data?.ToString(); } catch (Exception e) { Log.Error(e); } UpdateOutputType(); }
protected override void DrawConnections(NodeInput input, float inputID) { }
public UINode(Node n, UIGraph graph, double ox, double oy, double xs, double xy, double sc = 1) { InitializeComponent(); Focusable = true; InputNodes = new List <UINodePoint>(); OutputNodes = new List <UINodePoint>(); Graph = graph; xShift = xs; yShift = xy; scale = sc; Node = n; Id = n.Id; originX = ox; originY = oy; NodeName.Text = n.Name; for (int i = 0; i < n.Outputs.Count; i++) { NodeOutput op = n.Outputs[i]; UINodePoint outpoint = new UINodePoint(this, graph); outpoint.Output = op; outpoint.VerticalAlignment = VerticalAlignment.Center; OutputNodes.Add(outpoint); OutputStack.Children.Add(outpoint); } for (int i = 0; i < n.Inputs.Count; i++) { NodeInput inp = n.Inputs[i]; UINodePoint inputpoint = new UINodePoint(this, graph); inputpoint.Input = inp; inputpoint.VerticalAlignment = VerticalAlignment.Center; InputStack.Children.Add(inputpoint); InputNodes.Add(inputpoint); } n.OnNameUpdate += N_OnNameUpdate; n.OnInputAddedToNode += N_OnInputAddedToNode; n.OnInputRemovedFromNode += N_OnInputRemovedFromNode; n.OnOutputAddedToNode += N_OnOutputAddedToNode; n.OnOutputRemovedFromNode += N_OnOutputRemovedFromNode; n.OnDescriptionChanged += N_OnDescriptionChanged; if (n is MathNode) { DescPreview.Visibility = Visibility.Visible; Desc.Text = n.GetDescription(); LoadIcon(); } if (graph.Graph is FunctionGraph) { FunctionGraph f = graph.Graph as FunctionGraph; f.OnOutputSet += F_OnOutputSet; if (n == f.OutputNode) { OutputIcon.Visibility = Visibility.Visible; DescPreview.Background = HighlightBrush; } else { DescPreview.Background = DefaultBrush; OutputIcon.Visibility = Visibility.Collapsed; } if (n == f.Execute) { InputIcon.Visibility = Visibility.Visible; } else { InputIcon.Visibility = Visibility.Collapsed; } } else { if (n is OutputNode) { OutputIcon.Visibility = Visibility.Visible; } else { OutputIcon.Visibility = Visibility.Collapsed; } if (n is InputNode) { InputIcon.Visibility = Visibility.Visible; } else { InputIcon.Visibility = Visibility.Collapsed; } } }
private void OnInputRemoved(NodeInput n) { TryAndProcess(); }
protected void DrawInputLines() { Handles.BeginGUI(); Handles.color = Color.white; for (int i = 0; i < nodeInputs.Count; i++) { if (nodeInputs[i].inputNode != null && nodeInputs[i].isOccupied) { DrawNodeConnection(nodeInputs[i], (float)(i + 1)); } else { nodeInputs[i] = new NodeInput(); } } Handles.EndGUI(); }
public NEnd() { input = new NodeInput(); input.inputNode = new List <NTemplate>(); }
public virtual void OnAddConnection (NodeInput input) {}
private void Input_OnInputChanged(NodeInput n) { TryAndProcess(); }
public FloatNode() : base() { inputs = new NodeInput[] { new NodeInput(this, 0) }; outputs = new NodeOutput[] { new NodeOutput(this, typeof(float), 0) }; }
public MapOutputNode() { inputA = new NodeInput(); }
/// <summary> /// Processes input events /// </summary> private void InputEvents() { Event e = Event.current; mousePos = e.mousePosition; Node clickedNode = null; if (e.type == EventType.MouseDown || e.type == EventType.MouseUp) { clickedNode = NodeAtPosition(e.mousePosition); } if (e.type == EventType.Repaint) { // Draw background when repainting Vector2 offset = new Vector2(nodeCanvas.scrollOffset.x % Background.width - Background.width, nodeCanvas.scrollOffset.y % Background.height - Background.height); int tileX = Mathf.CeilToInt((position.width + (Background.width - offset.x)) / Background.width); int tileY = Mathf.CeilToInt((position.height + (Background.height - offset.y)) / Background.height); for (int x = 0; x < tileX; x++) { for (int y = 0; y < tileY; y++) { Rect texRect = new Rect(offset.x + x * Background.width, offset.y + y * Background.height, Background.width, Background.height); GUI.DrawTexture(texRect, Background); } } } if (e.type == EventType.MouseDown) { activeNode = clickedNode; connectOutput = null; if (clickedNode != null) { // A click on a node if (e.button == 1) { // Right click -> Node Context Click GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete Node"), false, ContextCallback, "deleteNode"); menu.ShowAsContext(); e.Use(); } else if (e.button == 0) { /* // Handled by Unity. For new Windowing System * // Left click -> check for drag on the header and for transition edits, else let it pass for gui elements * if (new Rect (clickedNode.rect.x, clickedNode.rect.y, clickedNode.rect.width, 40).Contains (mousePos)) * { // We clicked the header, so we'll drag the node * dragNode = true; * e.delta = new Vector2 (0, 0); * }*/ // If a Connection was left clicked, try edit it's transition NodeOutput nodeOutput = clickedNode.GetOutputAtPos(mousePos); if (nodeOutput != null) { // Output Node -> New Connection drawn from this connectOutput = nodeOutput; e.Use(); } else { // no output clicked, check input NodeInput nodeInput = clickedNode.GetInputAtPos(mousePos); if (nodeInput != null && nodeInput.connection != null) { // Input node -> Loose and edit Connection connectOutput = nodeInput.connection; nodeInput.connection.connections.Remove(nodeInput); nodeInput.connection = null; e.Use(); } // Nothing interesting for us in the node clicked, so let the event pass to gui elements } } } else if (!sideWindowRect.Contains(mousePos)) { // A click on the empty canvas if (e.button == 2 || e.button == 0) { // Left/Middle Click -> Start scrolling scrollWindow = true; e.delta = new Vector2(0, 0); } else if (e.button == 1) { // Right click -> Editor Context Click GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("오브젝트 추가"), false, ContextCallback, "objectNode"); menu.AddItem(new GUIContent("아이템 추가"), false, ContextCallback, "itemNode"); menu.AddItem(new GUIContent("조건 추가"), false, ContextCallback, "conditionNode"); menu.AddSeparator(""); menu.ShowAsContext(); e.Use(); } } } else if (e.type == EventType.MouseUp) { if (connectOutput != null) { // Apply a connection if theres a clicked input if (clickedNode != null) //&& !clickedNode.Outputs.Contains (connectOutput)) { // If an input was clicked, it'll will now be connected NodeInput clickedInput = clickedNode.GetInputAtPos(mousePos); if (Node.CanApplyConnection(connectOutput, clickedInput)) { // If it can connect (type is equals, it does not cause recursion, ...) Node.ApplyConnection(connectOutput, clickedInput); } } e.Use(); } else if (e.button == 2 || e.button == 0) { // Left/Middle click up -> Stop scrolling scrollWindow = false; } connectOutput = null; } else if (e.type == EventType.KeyDown) { if (e.keyCode == KeyCode.N) // Start Navigating (curve to origin) { navigate = true; } } else if (e.type == EventType.KeyUp) { if (e.keyCode == KeyCode.N) // Stop Navigating { navigate = false; } } else if (e.type == EventType.Repaint) { if (navigate) { // Draw a curve to the origin/active node for orientation purposes DrawNodeCurve(nodeCanvas.scrollOffset, (activeNode != null? activeNode.rect.center : e.mousePosition)); Repaint(); } if (connectOutput != null) { // Draw the currently drawn connection DrawNodeCurve(connectOutput.GetKnob().center, e.mousePosition); Repaint(); } } if (scrollWindow) { // Scroll everything with the current mouse delta nodeCanvas.scrollOffset += e.delta / 2; for (int nodeCnt = 0; nodeCnt < nodeCanvas.nodes.Count; nodeCnt++) { nodeCanvas.nodes [nodeCnt].rect.position += e.delta / 2; } Repaint(); } /* // Handled by Unity. For new Windowing System * if (dragNode) * { // Drag the active node with the current mouse delt * activeNode.rect.position += e.delta / 2; * Repaint (); * }*/ }
private Entity setInputEntity(NodeInput nodeinput) { //check whether the previous node had multiple outputs //if yes, get the proper "child" entity if (nodeinput.inputNode.nodeOutputs.Count > 1) { Debug.Assert(!(nodeinput.outputPos > nodeinput.inputNode.nodeOutputs.Count - 1), "mismatch between number of node outputs and assigned output slot"); return nodeinput.inputNode.entity.entities[nodeinput.outputPos]; } //if no, get the "root" entity else { return nodeinput.inputNode.entity; } }
private void Input_OnInputRemoved(NodeInput n) { Updated(); }
protected void DrawNodeConnection(NodeInput currentInput, float inputId) { //Draws NodeCurves between nodes in the highest parentGraph and single Input Handles if (!currentInput.inputNode.multiOutput && !multiInput && currentInput.inputNode.parentGraph == parentGraph) { DrawUtilities.DrawNodeCurve(currentInput.getOutputPosRect(), currentInput.rect, WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } else if (currentInput.inputNode.parentGraph == parentGraph && currentInput.inputNode.multiOutput && !multiInput) { DrawUtilities.DrawNodeCurve(currentInput.inputNode.getMultiOutputRect(), currentInput.rect, WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } else if (currentInput.inputNode.parentGraph == parentGraph && currentInput.inputNode.multiOutput && multiInput) { DrawUtilities.DrawNodeCurve(currentInput.inputNode.getMultiOutputRect(), getMultiInputRect(), WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness + currentInput.inputNode.nodeOutputs.Count); } else if(currentInput.inputNode.parentGraph != parentGraph)//Draws NodeCurves between the leftside Handles of a child Graph to the Nodes { if (parentGraph.graphNode != null) { int i = parentGraph.graphNode.nodeInputs.FindIndex(a => a.inputNode == currentInput.inputNode); if (i >= 0) { Rect r = parentGraph.graphInputRects[i]; DrawUtilities.DrawNodeCurve(new Vector3(r.x + r.width, r.center.y, 0f), nodeRect, inputId, nodeInputs.Count); } else { if(currentInput.inputNode.parentGraph.graphNode != null) { if (currentInput.inputNode.parentGraph.graphNode.multiOutput && !multiInput) { DrawUtilities.DrawNodeCurve(currentInput.inputNode.parentGraph.graphNode.getMultiOutputRect(), currentInput.rect, WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } else if (currentInput.inputNode.parentGraph.graphNode.multiOutput && multiInput) { DrawUtilities.DrawNodeCurve(currentInput.inputNode.parentGraph.graphNode.getMultiOutputRect(), getMultiInputRect(), WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness + currentInput.inputNode.nodeOutputs.Count); } else { DrawUtilities.DrawNodeCurve(currentInput.inputNode.parentGraph.graphNode.nodeOutputs[currentInput.outputPos].rect, currentInput.rect, WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } } } } else { if (currentInput.inputNode.parentGraph.graphNode.nodeOutputs.Count > 0) { if (currentInput.inputNode.parentGraph.graphNode.multiOutput && !multiInput) { DrawUtilities.DrawNodeCurve(currentInput.inputNode.parentGraph.graphNode.getMultiOutputRect(), currentInput.rect, WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } else if (currentInput.inputNode.parentGraph.graphNode.multiOutput && multiInput) { DrawUtilities.DrawNodeCurve(currentInput.inputNode.parentGraph.graphNode.getMultiOutputRect(), getMultiInputRect(), WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } else if (!currentInput.inputNode.parentGraph.graphNode.multiOutput && multiInput) { DrawUtilities.DrawNodeCurve(currentInput.inputNode.parentGraph.graphNode.nodeOutputs[currentInput.outputPos].rect, getMultiInputRect(), WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } else { DrawUtilities.DrawNodeCurve(currentInput.inputNode.parentGraph.graphNode.nodeOutputs[currentInput.outputPos].rect, currentInput.rect, WorkPreferences.nodeCurveColor, WorkPreferences.nodeCurveThickness); } } } } else { //Draws the MultiInput Curve between single Outputs to MultiInputs DrawUtilities.DrawMultiInputNodeCurve(currentInput.inputNode.nodeRect, nodeRect, 1); } }
public ComponentPropertyNode() : base() { inputs = new NodeInput[] { new NodeInput(this, 0) }; outputs = new NodeOutput[] { new NodeOutput(this, typeof(object), 0) }; }
public virtual void OnRemoveConnection (NodeInput input) {}
public AddNode() { output = new NodeOutput(); inputA = new NodeInput(); inputB = new NodeInput(); }
public AddNode() { this.output = new NodeOutput(); this.inputA = new NodeInput(); this.inputB = new NodeInput(); }
public Connection(NodeOutput nodeOutput, NodeInput nodeInput) { output = nodeOutput; input = nodeInput; }
/// <summary> /// Removes the connection from NodeInput. /// </summary> public static void RemoveConnection(NodeInput input) { NodeEditorCallbacks.IssueOnRemoveConnection (input); input.connection.connections.Remove (input); input.connection = null; NodeEditor.RecalculateFrom (input.body); }
public override void OnNewInputConnection(NodeInput addedInput) { //_meshOutput = Modify(addedInput.GetValue<Mesh[]>()); }
public override sealed void AddInput(NodeInput input) { }
/// <summary> /// Applies a connection between output and input. 'CanApplyConnection' has to be checked before /// </summary> public static void ApplyConnection (NodeOutput output, NodeInput input) { if (input != null && output != null) { if (input.Connection != null) input.Connection.Connections.Remove (input); input.Connection = output; output.Connections.Add (input); NodeEditor.RecalculateFrom (input.Body); output.Body.OnAddOutputConnection (output); input.Body.OnAddInputConnection (input); NodeEditorCallbacks.IssueOnAddConnection (input); } }