private void ApplyNodeProperty(INodeProperty property, Identifier identifier) { var node = _nodes[identifier]; property.Apply(node, _debuggerOperations, identifier); }
public void FromINodeProperty(INodeProperty property) { if (!(property is LabelNodeProperty)) { return; } FromAbstractLabelProperty((LabelNodeProperty)property); }
public void FromINodeProperty(INodeProperty property) { if (!(property is LineWidthNodeProperty lineWidthNodeProperty)) { return; } CheckBox.IsChecked = true; TextBox.Text = $"{lineWidthNodeProperty.LineWidth:0.00}"; }
public void FromINodeProperty(INodeProperty property) { if (!(property is FillColorNodeProperty fillColorNodeProperty)) { return; } CheckBox.IsChecked = true; SetColor(fillColorNodeProperty.Color); }
public void FromINodeProperty(INodeProperty property) { if (!(property is StyleNodeProperty)) { return; } FromProperty(() => ((StyleNodeProperty)property).Style); }
public void AddShaderProperty(INodeProperty property) { if (property == null) { return; } if (m_Properties.Contains(property)) { return; } m_Properties.Add(property); m_PropertyDictionary.Add(property.guid, property); m_AddedProperties.Add(property); }
public void FromINodeProperty(INodeProperty property) { if (!(property is ShapeNodeProperty)) { return; } var shapeProperty = (ShapeNodeProperty)property; var shapeName = ShapesToMsaglTypes.FirstOrDefault(x => x.Value == shapeProperty.Shape).Key; if (shapeName == null) { return; } CheckBox.IsChecked = true; _shapeRadioButtons.Where(r => (string)r.Content == shapeName).ToList().ForEach(r => r.IsChecked = true); }
void AddProperty(INodeProperty property, bool create = false, int index = -1) { if (m_PropertyRows.ContainsKey(property.guid)) { return; } if (create) { property.displayName = m_Graph.SanitizePropertyName(property.displayName); } var field = new BlackboardField(m_ExposedIcon, property.displayName, property.propertyType.ToString()) { userData = property }; var row = new BlackboardRow(field, new BlackboardFieldPropertyView(m_Graph, property)); row.userData = property; if (index < 0) { index = m_PropertyRows.Count; } if (index == m_PropertyRows.Count) { m_Section.Add(row); } else { m_Section.Insert(index, row); } m_PropertyRows[property.guid] = row; if (create) { row.expanded = true; m_Graph.owner.RegisterCompleteObjectUndo("Create Property"); m_Graph.AddShaderProperty(property); field.OpenTextEditor(); } }
void CreateNode(object obj, Vector2 nodePosition) { var blackboardField = obj as BlackboardField; if (blackboardField != null) { INodeProperty property = blackboardField.userData as INodeProperty; if (property != null) { graph.owner.RegisterCompleteObjectUndo("Drag Property"); var node = new PropertyNode(); var drawState = node.drawState; drawState.position = new Rect(nodePosition, drawState.position.size); node.drawState = drawState; graph.AddNode(node); node.propertyGuid = property.guid; } } }
public void MoveShaderProperty(INodeProperty property, int newIndex) { if (newIndex > m_Properties.Count || newIndex < 0) { throw new ArgumentException("New index is not within properties list."); } var currentIndex = m_Properties.IndexOf(property); if (currentIndex == -1) { throw new ArgumentException("Property is not in graph."); } if (newIndex == currentIndex) { return; } m_Properties.RemoveAt(currentIndex); if (newIndex > currentIndex) { newIndex--; } var isLast = newIndex == m_Properties.Count; if (isLast) { m_Properties.Add(property); } else { m_Properties.Insert(newIndex, property); } if (!m_MovedProperties.Contains(property)) { m_MovedProperties.Add(property); } }
public BlackboardFieldPropertyView(AbstractNodeGraph graph, INodeProperty property) { styleSheets.Add(Resources.Load <StyleSheet>("Styles/NodeGraphBlackboard")); m_Graph = graph; m_Reference = new TextField(); m_Reference.RegisterValueChangedCallback(evt => { property.reference = evt.newValue; DirtyNodes(ModificationScope.Graph); }); m_Reference.value = property.reference; AddRow("Reference", m_Reference); if (property is ValueProperty <float> ) { var floatProperty = (ValueProperty <float>)property; FloatField floatField = new FloatField { value = floatProperty.value }; floatField.RegisterValueChangedCallback(evt => { floatProperty.value = (float)evt.newValue; DirtyNodes(); }); AddRow("Default", floatField); /*if (floatProperty.floatType == FloatType.Slider) * { * var minField = new FloatField { value = floatProperty.rangeValues.x }; * minField.OnValueChanged(minEvt => * { * floatProperty.rangeValues = new Vector2((float)minEvt.newValue, floatProperty.rangeValues.y); * floatProperty.value = Mathf.Max(Mathf.Min(floatProperty.value, floatProperty.rangeValues.y), floatProperty.rangeValues.x); * floatField.value = floatProperty.value; * DirtyNodes(); * }); * minRow = AddRow("Min", minField); * var maxField = new FloatField { value = floatProperty.rangeValues.y }; * maxField.OnValueChanged(maxEvt => * { * floatProperty.rangeValues = new Vector2(floatProperty.rangeValues.x, (float)maxEvt.newValue); * floatProperty.value = Mathf.Max(Mathf.Min(floatProperty.value, floatProperty.rangeValues.y), floatProperty.rangeValues.x); * floatField.value = floatProperty.value; * DirtyNodes(); * }); * maxRow = AddRow("Max", maxField); * }*/ } else if (property is ValueProperty <int> ) { var intProperty = (ValueProperty <int>)property; var field = new IntegerField { value = intProperty.value }; field.RegisterValueChangedCallback(intEvt => { intProperty.value = intEvt.newValue; DirtyNodes(); }); AddRow("Default", field); } else if (property is ValueProperty <Vector2> ) { var vectorProperty = (ValueProperty <Vector2>)property; var field = new Vector2Field { value = vectorProperty.value }; field.RegisterValueChangedCallback(evt => { vectorProperty.value = evt.newValue; DirtyNodes(); }); AddRow("Default", field); } else if (property is ValueProperty <Vector3> ) { var vectorProperty = (ValueProperty <Vector3>)property; var field = new Vector3Field { value = vectorProperty.value }; field.RegisterValueChangedCallback(evt => { vectorProperty.value = evt.newValue; DirtyNodes(); }); AddRow("Default", field); } else if (property is ValueProperty <Vector4> ) { var vectorProperty = (ValueProperty <Vector4>)property; var field = new Vector4Field { value = vectorProperty.value }; field.RegisterValueChangedCallback(evt => { vectorProperty.value = evt.newValue; DirtyNodes(); }); AddRow("Default", field); } else if (property is ValueProperty <Color> ) { var colorProperty = (ValueProperty <Color>)property; //todo add HDR var colorField = new ColorField { value = (Color)property.defaultValue, showEyeDropper = false }; colorField.RegisterValueChangedCallback(evt => { colorProperty.value = evt.newValue; DirtyNodes(); }); AddRow("Default", colorField); } else if (property is ValueProperty <Texture2D> ) { var textureProperty = (ValueProperty <Texture2D>)property; var field = new ObjectField { value = textureProperty.value, objectType = typeof(Texture2D) }; field.RegisterValueChangedCallback(evt => { textureProperty.value = (Texture2D)evt.newValue; DirtyNodes(); }); AddRow("Default", field); } else if (property is ValueProperty <Cubemap> ) { var cubemapProperty = (ValueProperty <Cubemap>)property; var field = new ObjectField { value = cubemapProperty.value, objectType = typeof(Cubemap) }; field.RegisterValueChangedCallback(evt => { cubemapProperty.value = (Cubemap)evt.newValue; DirtyNodes(); }); AddRow("Default", field); } else if (property is ValueProperty <bool> ) { var booleanProperty = (ValueProperty <bool>)property; EventCallback <ChangeEvent <bool> > onBooleanChanged = evt => { booleanProperty.value = evt.newValue; DirtyNodes(); }; var field = new Toggle(); field.RegisterValueChangedCallback(onBooleanChanged); field.value = booleanProperty.value; AddRow("Default", field); } // AddRow("Type", new TextField()); // AddRow("Exposed", new Toggle(null)); // AddRow("Range", new Toggle(null)); // AddRow("Default", new TextField()); // AddRow("Tooltip", new TextField()); AddToClassList("sgblackboardFieldPropertyView"); }
internal static void InsertCopyPasteGraph(this NodeGraphView graphView, CopyPasteGraph copyGraph) { if (copyGraph == null) { return; } // Make new properties from the copied graph foreach (INodeProperty property in copyGraph.properties) { string propertyName = graphView.graph.SanitizePropertyName(property.displayName); INodeProperty copiedProperty = property.Copy(); copiedProperty.displayName = propertyName; graphView.graph.AddShaderProperty(copiedProperty); // Update the property nodes that depends on the copied node var dependentPropertyNodes = copyGraph.GetNodes <PropertyNode>().Where(x => x.propertyGuid == property.guid); foreach (var node in dependentPropertyNodes) { node.SetOwner(graphView.graph); node.propertyGuid = copiedProperty.guid; } } using (var remappedNodesDisposable = ListPool <INode> .GetDisposable()) { using (var remappedEdgesDisposable = ListPool <IEdge> .GetDisposable()) { var remappedNodes = remappedNodesDisposable.value; var remappedEdges = remappedEdgesDisposable.value; graphView.graph.PasteGraph(copyGraph, remappedNodes, remappedEdges); if (graphView.graph.guid != copyGraph.sourceGraphGuid) { // Compute the mean of the copied nodes. Vector2 centroid = Vector2.zero; var count = 1; foreach (var node in remappedNodes) { var position = node.drawState.position.position; centroid = centroid + (position - centroid) / count; ++count; } // Get the center of the current view var viewCenter = graphView.contentViewContainer.WorldToLocal(graphView.layout.center); foreach (var node in remappedNodes) { var drawState = node.drawState; var positionRect = drawState.position; var position = positionRect.position; position += viewCenter - centroid; positionRect.position = position; drawState.position = positionRect; node.drawState = drawState; } } // Add new elements to selection graphView.ClearSelection(); graphView.graphElements.ForEach(element => { var edge = element as UnityEditor.Experimental.UIElements.GraphView.Edge; if (edge != null && remappedEdges.Contains(edge.userData as IEdge)) { graphView.AddToSelection(edge); } var nodeView = element as NodeView; if (nodeView != null && remappedNodes.Contains(nodeView.node)) { graphView.AddToSelection(nodeView); } }); } } }
public int GetShaderPropertyIndex(INodeProperty property) { return(m_Properties.IndexOf(property)); }
public void AddMetaProperty(INodeProperty metaProperty) { m_MetaProperties.Add(metaProperty); }
public void AddProperty(INodeProperty property) { m_Properties.Add(property); }