Skip to content

Commit 2981e68

Browse files
iTris666GitHub Enterprise
authored andcommitted
Fix square complexity on parameter to serialized property matching (#78)
* Fix square complexity on parameter to serialized property matching * Update CHANGELOG.md
1 parent 453feba commit 2981e68

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ The version number for this package has increased due to a version update of a r
136136
- Make VisualEffect created from the GameObject menu have unique names [Case 1262989](https://issuetracker.unity3d.com/product/unity/issues/guid/1262989/)
137137
- Missing System Seed in new dynamic built-in operator.
138138
- Prefab highlight missing for initial event name toggle [Case 1263012](https://issuetracker.unity3d.com/product/unity/issues/guid/1263012/)
139+
- Optimize display of inspector when there is a lot of exposed VFX properties.
139140
- fixes the user created vfx default resources that were ignored unless loaded
140141
- fix crash when creating a loop in subgraph operators [Case 1251523](https://issuetracker.unity3d.com/product/unity/issues/guid/1251523/)
141142
- Normals with non uniform scales are correctly computed [Case 1246989](https://issuetracker.unity3d.com/product/unity/issues/guid/1246989/)

com.unity.visualeffectgraph/Editor/Inspector/VisualEffectEditor.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,9 @@ public override void OnInspectorGUI()
783783
GUI.enabled = true;
784784
}
785785

786+
787+
Dictionary<string, Dictionary<string, SerializedProperty>> m_PropertyToProp = new Dictionary<string, Dictionary<string, SerializedProperty>>();
788+
786789
protected virtual void DrawParameters(VisualEffectResource resource)
787790
{
788791
var component = (VisualEffect)target;
@@ -804,6 +807,25 @@ protected virtual void DrawParameters(VisualEffectResource resource)
804807
graph.BuildParameterInfo();
805808
}
806809

810+
811+
m_PropertyToProp.Clear();
812+
813+
foreach (var sheetType in graph.m_ParameterInfo.Select(t => t.sheetType).Where(t=>!string.IsNullOrEmpty(t)).Distinct())
814+
{
815+
var nameToIndices = new Dictionary<string, SerializedProperty>();
816+
817+
var sourceVfxField = m_VFXPropertySheet.FindPropertyRelative(sheetType + ".m_Array");
818+
for (int i = 0; i < sourceVfxField.arraySize; ++i)
819+
{
820+
SerializedProperty sourceProperty = sourceVfxField.GetArrayElementAtIndex(i);
821+
var nameProperty = sourceProperty.FindPropertyRelative("m_Name").stringValue;
822+
823+
nameToIndices[nameProperty] = sourceProperty;
824+
}
825+
m_PropertyToProp[sheetType] = nameToIndices;
826+
}
827+
828+
807829
if (graph.m_ParameterInfo != null)
808830
{
809831
bool newShowParameterCategory = ShowHeader(Contents.headerProperties, true, showPropertyCategory);
@@ -876,20 +898,10 @@ protected virtual void DrawParameters(VisualEffectResource resource)
876898
}
877899
}
878900
else if (!ignoreUntilNextCat)
879-
{
880-
//< Try find source property
881-
var sourceVfxField = m_VFXPropertySheet.FindPropertyRelative(parameter.sheetType + ".m_Array");
901+
{
882902
SerializedProperty sourceProperty = null;
883-
for (int i = 0; i < sourceVfxField.arraySize; ++i)
884-
{
885-
sourceProperty = sourceVfxField.GetArrayElementAtIndex(i);
886-
var nameProperty = sourceProperty.FindPropertyRelative("m_Name").stringValue;
887-
if (nameProperty == parameter.path)
888-
{
889-
break;
890-
}
891-
sourceProperty = null;
892-
}
903+
904+
m_PropertyToProp[parameter.sheetType].TryGetValue(parameter.path, out sourceProperty);
893905

894906
//< Prepare potential indirection
895907
bool wasNewProperty = false;
@@ -1032,6 +1044,7 @@ protected virtual void DrawParameters(VisualEffectResource resource)
10321044
}
10331045
if (wasNewProperty)
10341046
{
1047+
var sourceVfxField = m_VFXPropertySheet.FindPropertyRelative(parameter.sheetType + ".m_Array");
10351048
//We start editing a new exposed value which wasn't stored in this Visual Effect Component
10361049
sourceVfxField.InsertArrayElementAtIndex(sourceVfxField.arraySize);
10371050
var newEntry = sourceVfxField.GetArrayElementAtIndex(sourceVfxField.arraySize - 1);

0 commit comments

Comments
 (0)