@@ -1672,40 +1672,49 @@ public ShaderInput AddCopyOfShaderInput(ShaderInput source, int insertIndex = -1
16721672 return copy ;
16731673 }
16741674
1675- public void RemoveGraphInput ( ShaderInput input )
1675+ // Removes a collection of shader inputs, deferring graph validation until all inputs have been removed
1676+ public void RemoveGraphInputs ( IEnumerable < ShaderInput > inputs )
16761677 {
1677- switch ( input )
1678+ foreach ( ShaderInput input in inputs )
16781679 {
1679- case AbstractShaderProperty property :
1680- var propertyNodes = GetNodes < PropertyNode > ( ) . Where ( x => x . property == input ) . ToList ( ) ;
1681- foreach ( var propertyNode in propertyNodes )
1682- ReplacePropertyNodeWithConcreteNodeNoValidate ( propertyNode ) ;
1683- break ;
1684- }
1680+ switch ( input )
1681+ {
1682+ case AbstractShaderProperty property :
1683+ var propertyNodes = GetNodes < PropertyNode > ( ) . Where ( x => x . property == input ) . ToList ( ) ;
1684+ foreach ( var propertyNode in propertyNodes )
1685+ ReplacePropertyNodeWithConcreteNodeNoValidate ( propertyNode ) ;
1686+ break ;
1687+ }
16851688
1686- // Also remove this input from any category it existed in
1687- foreach ( var categoryData in categories )
1688- {
1689- if ( categoryData . IsItemInCategory ( input ) )
1689+ // Also remove this input from any category it existed in
1690+ foreach ( var categoryData in categories )
16901691 {
1691- categoryData . RemoveItemFromCategory ( input ) ;
1692- break ;
1692+ if ( categoryData . IsItemInCategory ( input ) )
1693+ {
1694+ categoryData . RemoveItemFromCategory ( input ) ;
1695+ break ;
1696+ }
16931697 }
1694- }
16951698
1696- foreach ( var node in GetNodes < SubGraphNode > ( ) )
1697- {
1698- if ( node . UsedReferenceNames ( ) . Contains ( input . referenceName ) )
1699+ foreach ( var node in GetNodes < SubGraphNode > ( ) )
16991700 {
1700- node . ValidateNode ( ) ;
1701- node . Dirty ( ModificationScope . Graph ) ;
1701+ if ( node . UsedReferenceNames ( ) . Contains ( input . referenceName ) )
1702+ {
1703+ node . ValidateNode ( ) ;
1704+ node . Dirty ( ModificationScope . Graph ) ;
1705+ }
17021706 }
1703- }
17041707
1705- RemoveGraphInputNoValidate ( input ) ;
1708+ RemoveGraphInputNoValidate ( input ) ;
1709+ }
17061710 ValidateGraph ( ) ;
17071711 }
17081712
1713+ public void RemoveGraphInput ( ShaderInput input )
1714+ {
1715+ RemoveGraphInputs ( new ShaderInput [ ] { input } ) ;
1716+ }
1717+
17091718 public void MoveCategory ( CategoryData category , int newIndex )
17101719 {
17111720 if ( newIndex > m_CategoryData . Count || newIndex < 0 )
@@ -1890,8 +1899,7 @@ public void RemoveCategory(string categoryGUID)
18901899 m_RemovedCategories . Add ( existingCategory ) ;
18911900
18921901 // Whenever a category is removed, also remove any inputs within that category
1893- foreach ( var shaderInput in existingCategory . Children )
1894- RemoveGraphInput ( shaderInput ) ;
1902+ RemoveGraphInputs ( existingCategory . Children ) ;
18951903 }
18961904 else
18971905 AssertHelpers . Fail ( "Attempted to remove a category that does not exist in the graph." ) ;
0 commit comments