@@ -54,28 +54,26 @@ public void Delete ()
5454 throw new UnityException ( "The Node " + name + " does not exist on the Canvas " + NodeEditor . curNodeCanvas . name + "!" ) ;
5555 NodeEditorCallbacks . IssueOnDeleteNode ( this ) ;
5656 NodeEditor . curNodeCanvas . nodes . Remove ( this ) ;
57- for ( int outCnt = 0 ; outCnt < Outputs . Count ; outCnt ++ )
57+ foreach ( NodeOutput output in Outputs )
5858 {
59- NodeOutput output = Outputs [ outCnt ] ;
6059 while ( output . connections . Count != 0 )
6160 output . connections [ 0 ] . RemoveConnection ( ) ;
6261 DestroyImmediate ( output , true ) ;
6362 }
64- for ( int inCnt = 0 ; inCnt < Inputs . Count ; inCnt ++ )
63+ foreach ( NodeInput input in Inputs )
6564 {
66- NodeInput input = Inputs [ inCnt ] ;
6765 if ( input . connection != null )
6866 input . connection . connections . Remove ( input ) ;
6967 DestroyImmediate ( input , true ) ;
7068 }
71- for ( int knobCnt = 0 ; knobCnt < nodeKnobs . Count ; knobCnt ++ )
69+ foreach ( NodeKnob knob in nodeKnobs )
7270 { // Inputs/Outputs need specific treatment, unfortunately
73- if ( nodeKnobs [ knobCnt ] != null )
74- DestroyImmediate ( nodeKnobs [ knobCnt ] , true ) ;
71+ if ( knob != null )
72+ DestroyImmediate ( knob , true ) ;
7573 }
76- for ( int transCnt = 0 ; transCnt < transitions . Count ; transCnt ++ )
74+ foreach ( Transition transition in transitions )
7775 {
78- transitions [ transCnt ] . Delete ( ) ;
76+ transition . Delete ( ) ;
7977 }
8078 DestroyImmediate ( this , true ) ;
8179 }
@@ -244,8 +242,8 @@ protected internal virtual void DrawNode ()
244242 protected internal virtual void DrawKnobs ( )
245243 {
246244 CheckNodeKnobMigration ( ) ;
247- for ( int knobCnt = 0 ; knobCnt < nodeKnobs . Count ; knobCnt ++ )
248- nodeKnobs [ knobCnt ] . DrawKnob ( ) ;
245+ foreach ( NodeKnob knob in nodeKnobs )
246+ knob . DrawKnob ( ) ;
249247 }
250248
251249 /// <summary>
@@ -256,15 +254,13 @@ protected internal virtual void DrawConnections ()
256254 CheckNodeKnobMigration ( ) ;
257255 if ( Event . current . type != EventType . Repaint )
258256 return ;
259- for ( int outCnt = 0 ; outCnt < Outputs . Count ; outCnt ++ )
257+ foreach ( NodeOutput output in Outputs )
260258 {
261- NodeOutput output = Outputs [ outCnt ] ;
262259 Vector2 startPos = output . GetGUIKnob ( ) . center ;
263260 Vector2 startDir = output . GetDirection ( ) ;
264261
265- for ( int conCnt = 0 ; conCnt < output . connections . Count ; conCnt ++ )
262+ foreach ( NodeInput input in output . connections )
266263 {
267- NodeInput input = output . connections [ conCnt ] ;
268264 NodeEditorGUI . DrawConnection ( startPos ,
269265 startDir ,
270266 input . GetGUIKnob ( ) . center ,
@@ -279,10 +275,10 @@ protected internal virtual void DrawConnections ()
279275 /// </summary>
280276 public void DrawTransitions ( )
281277 {
282- for ( int cnt = 0 ; cnt < transitions . Count ; cnt ++ )
278+ foreach ( Transition transition in transitions )
283279 {
284- if ( transitions [ cnt ] . startNode == this )
285- transitions [ cnt ] . DrawFromStartNode ( ) ;
280+ if ( transition . startNode == this )
281+ transition . DrawFromStartNode ( ) ;
286282 }
287283 }
288284
@@ -301,9 +297,9 @@ public virtual void DrawNodePropertyEditor() { }
301297 /// </summary>
302298 protected internal bool allInputsReady ( )
303299 {
304- for ( int inCnt = 0 ; inCnt < Inputs . Count ; inCnt ++ )
300+ foreach ( NodeInput input in Inputs )
305301 {
306- if ( Inputs [ inCnt ] . connection == null || Inputs [ inCnt ] . connection . IsValueNull )
302+ if ( input . connection == null || input . connection . IsValueNull )
307303 return false ;
308304 }
309305 return true ;
@@ -313,8 +309,8 @@ protected internal bool allInputsReady ()
313309 /// </summary>
314310 protected internal bool hasUnassignedInputs ( )
315311 {
316- for ( int inCnt = 0 ; inCnt < Inputs . Count ; inCnt ++ )
317- if ( Inputs [ inCnt ] . connection == null )
312+ foreach ( NodeInput input in Inputs )
313+ if ( input . connection == null )
318314 return true ;
319315 return false ;
320316 }
@@ -324,9 +320,9 @@ protected internal bool hasUnassignedInputs ()
324320 /// </summary>
325321 protected internal bool descendantsCalculated ( )
326322 {
327- for ( int cnt = 0 ; cnt < Inputs . Count ; cnt ++ )
323+ foreach ( NodeInput input in Inputs )
328324 {
329- if ( Inputs [ cnt ] . connection != null && ! Inputs [ cnt ] . connection . body . calculated )
325+ if ( input . connection != null && ! input . connection . body . calculated )
330326 return false ;
331327 }
332328 return true ;
@@ -337,8 +333,8 @@ protected internal bool descendantsCalculated ()
337333 /// </summary>
338334 protected internal bool isInput ( )
339335 {
340- for ( int cnt = 0 ; cnt < Inputs . Count ; cnt ++ )
341- if ( Inputs [ cnt ] . connection != null )
336+ foreach ( NodeInput input in Inputs )
337+ if ( input . connection != null )
342338 return false ;
343339 return true ;
344340 }
@@ -386,10 +382,10 @@ protected void OutputKnob (int outputIdx)
386382 /// </summary>
387383 public NodeOutput GetOutputAtPos ( Vector2 pos )
388384 {
389- for ( int outCnt = 0 ; outCnt < Outputs . Count ; outCnt ++ )
385+ foreach ( NodeOutput output in Outputs )
390386 { // Search for an output at the position
391- if ( Outputs [ outCnt ] . GetScreenKnob ( ) . Contains ( new Vector3 ( pos . x , pos . y ) ) )
392- return Outputs [ outCnt ] ;
387+ if ( output . GetScreenKnob ( ) . Contains ( new Vector3 ( pos . x , pos . y ) ) )
388+ return output ;
393389 }
394390 return null ;
395391 }
@@ -434,10 +430,10 @@ protected void InputKnob (int inputIdx)
434430 /// </summary>
435431 public NodeInput GetInputAtPos ( Vector2 pos )
436432 {
437- for ( int inCnt = 0 ; inCnt < Inputs . Count ; inCnt ++ )
433+ foreach ( NodeInput input in Inputs )
438434 { // Search for an input at the position
439- if ( Inputs [ inCnt ] . GetScreenKnob ( ) . Contains ( new Vector3 ( pos . x , pos . y ) ) )
440- return Inputs [ inCnt ] ;
435+ if ( input . GetScreenKnob ( ) . Contains ( new Vector3 ( pos . x , pos . y ) ) )
436+ return input ;
441437 }
442438 return null ;
443439 }
@@ -454,9 +450,9 @@ public bool isChildOf (Node otherNode)
454450 if ( otherNode == null || otherNode == this )
455451 return false ;
456452 if ( BeginRecursiveSearchLoop ( ) ) return false ;
457- for ( int cnt = 0 ; cnt < Inputs . Count ; cnt ++ )
453+ foreach ( NodeInput input in Inputs )
458454 {
459- NodeOutput connection = Inputs [ cnt ] . connection ;
455+ NodeOutput connection = input . connection ;
460456 if ( connection != null )
461457 {
462458 if ( connection . body != startRecursiveSearchNode )
@@ -479,9 +475,9 @@ public bool isChildOf (Node otherNode)
479475 internal bool isInLoop ( )
480476 {
481477 if ( BeginRecursiveSearchLoop ( ) ) return this == startRecursiveSearchNode ;
482- for ( int cnt = 0 ; cnt < Inputs . Count ; cnt ++ )
478+ foreach ( NodeInput input in Inputs )
483479 {
484- NodeOutput connection = Inputs [ cnt ] . connection ;
480+ NodeOutput connection = input . connection ;
485481 if ( connection != null )
486482 {
487483 if ( connection . body . isInLoop ( ) )
@@ -507,9 +503,9 @@ internal bool allowsLoopRecursion (Node otherNode)
507503 if ( otherNode == null )
508504 return false ;
509505 if ( BeginRecursiveSearchLoop ( ) ) return false ;
510- for ( int cnt = 0 ; cnt < Inputs . Count ; cnt ++ )
506+ foreach ( NodeInput input in Inputs )
511507 {
512- NodeOutput connection = Inputs [ cnt ] . connection ;
508+ NodeOutput connection = input . connection ;
513509 if ( connection != null )
514510 {
515511 if ( connection . body != startRecursiveSearchNode )
@@ -534,11 +530,10 @@ public void ClearCalculation ()
534530 {
535531 if ( BeginRecursiveSearchLoop ( ) ) return ;
536532 calculated = false ;
537- for ( int outCnt = 0 ; outCnt < Outputs . Count ; outCnt ++ )
533+ foreach ( NodeOutput output in Outputs )
538534 {
539- NodeOutput output = Outputs [ outCnt ] ;
540- for ( int conCnt = 0 ; conCnt < output . connections . Count ; conCnt ++ )
541- output . connections [ conCnt ] . body . ClearCalculation ( ) ;
535+ foreach ( NodeInput connection in output . connections )
536+ connection . body . ClearCalculation ( ) ;
542537 }
543538 EndRecursiveSearchLoop ( ) ;
544539 }
@@ -608,4 +603,7 @@ public static void CreateTransition (Node fromNode, Node toNode)
608603
609604 #endregion
610605 }
606+
607+
608+
611609}
0 commit comments