Skip to content

Commit

Permalink
fixed graphdisplayattribute creategroup behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus committed Aug 21, 2023
1 parent 9bb0c41 commit 3c18e71
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.2.6] - 2023-03-14
### Fixed
- Removed unnecessary frame delay when reloading a graph [#2](https://github.com/Gentlymad-Studios/NewGraph/issues/2)
- Removed Unbind call when clearing a graph
- Removed Unbind call when clearing a graph
- PortListView entries will now update their name, if the referenced node name is changed

## [0.2.7] - 2023-03-15
Expand Down Expand Up @@ -233,4 +233,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.4.0] - 2023-07-10
### Fixed
- Fixed removing entire nodes when hitting the delete key while an input field was focussed.
- Fixed removing entire nodes when hitting the delete key while an input field was focussed.

## [0.4.1] - 2023-08-21
### Fixed
- Fixed GraphDisplayAttribute createGroup behavior
16 changes: 11 additions & 5 deletions Editor/Controllers/NodeController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GraphViewBase;
using GraphViewBase;
using System;
using System.Collections.Generic;
using UnityEditor;
Expand Down Expand Up @@ -80,12 +80,18 @@ public void DoForEachPropertyOrGroup(VisualElement[] parents, Func<GroupInfo, Vi

private void DoForEachPropertyOrGroupRecursive(VisualElement[] parents, List<PropertyInfo> propertiesIncludingGroups, Func<GroupInfo, VisualElement[], SerializedProperty, VisualElement[]> groupCreation, Action<VisualElement[], GraphPropertyInfo, SerializedProperty> propCreation) {
foreach (PropertyInfo groupOrProperty in propertiesIncludingGroups) {

if (groupOrProperty.GetType() == typeof(GroupInfo)) {
GroupInfo groupInfo = (GroupInfo)groupOrProperty;
if (groupInfo.graphProperties.Count > 0) {
VisualElement[] groupParents = groupCreation(groupInfo, parents, nodeDataProperty.FindPropertyRelative(groupOrProperty.relativePropertyPath));
DoForEachPropertyOrGroupRecursive(groupParents, groupInfo.graphProperties, groupCreation, propCreation);
}

if (!groupInfo.graphDisplay.createGroup) {
propCreation(parents, (GraphPropertyInfo)groupOrProperty, nodeDataProperty.FindPropertyRelative(groupOrProperty.relativePropertyPath));
} else {
if (groupInfo.graphProperties.Count > 0) {
VisualElement[] groupParents = groupCreation(groupInfo, parents, nodeDataProperty.FindPropertyRelative(groupOrProperty.relativePropertyPath));
DoForEachPropertyOrGroupRecursive(groupParents, groupInfo.graphProperties, groupCreation, propCreation);
}
}
} else {
propCreation(parents, (GraphPropertyInfo)groupOrProperty, nodeDataProperty.FindPropertyRelative(groupOrProperty.relativePropertyPath));
}
Expand Down
6 changes: 4 additions & 2 deletions Editor/Serialization/PropertyBag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ private int RetrieveCurrentAttributes() {
if (graphProperty.graphDisplay.displayType != DisplayType.Hide) {
// check if we have a generic object, that is not an array.
// if this is the case, we need to wrap it in a group and ignore the object itself, as all upcoming child properties will be drawn
if (!IsRealArray(currentProperty) && graphProperty.graphDisplay.createGroup && (currentProperty.propertyType == SerializedPropertyType.Generic || currentProperty.propertyType == SerializedPropertyType.ManagedReference)) {
// create a new group
if (!IsRealArray(currentProperty) && (currentProperty.propertyType == SerializedPropertyType.Generic || currentProperty.propertyType == SerializedPropertyType.ManagedReference)) {
// create a new group
GroupInfo groupInfo = new GroupInfo(currentProperty.displayName, currentRelativePropertyPath, currentGraphDisplayAttribute);

// check if the new group should be part of another group and add it to the group graphPropertiesAndGroups
Expand Down Expand Up @@ -306,6 +306,8 @@ private void FindGroupAndAdd(ref string relativePath, GraphPropertyInfo property
}
} else {
graphPropertiesAndGroups.Add(propertyInfo);


}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.gentlymad.newgraph",
"version": "0.4.0",
"version": "0.4.1",
"displayName": "NewGraph",
"description": "A general data oriented node graph solution. This is build upon the idea to visualize complex data structures as graph networks without having to modify already established data classes, except adding [Node], [Port] and [SerializeReference] attributes to call classes that should show in the Graph View.",
"unity": "2022.2",
Expand Down

0 comments on commit 3c18e71

Please sign in to comment.