From 330bd4116ec311d8c96cfd938f44600b2e209dab Mon Sep 17 00:00:00 2001 From: sp-francisco-ruiz Date: Fri, 26 May 2017 08:26:55 +0200 Subject: [PATCH 1/3] Refactor foreach loops into for loops. Removed unused Linq using statement --- Assets/Demo/scripts/TweenChainGUI.cs | 7 ++++--- Assets/Demo/scripts/TweenFlowGUI.cs | 15 ++++++--------- Assets/Editor/GoDummyPathEditor.cs | 1 - Assets/Plugins/GoKit/Go.cs | 16 +++++++++------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Assets/Demo/scripts/TweenChainGUI.cs b/Assets/Demo/scripts/TweenChainGUI.cs index ca08e9a..719387d 100644 --- a/Assets/Demo/scripts/TweenChainGUI.cs +++ b/Assets/Demo/scripts/TweenChainGUI.cs @@ -25,10 +25,11 @@ void Start() chain.setOnCompleteHandler( c => Debug.Log( "chain complete" ) ); // create a Tween for each cube and it to the chain - foreach( var cube in cubes ) + for(int i = 0; i < cubes.Length; ++i) { - var tween = new GoTween( cube, 0.5f, config ); - chain.append( tween ); + var cube = cubes[i]; + var tween = new GoTween(cube, 0.5f, config); + hain.append(tween); } _tween = chain; diff --git a/Assets/Demo/scripts/TweenFlowGUI.cs b/Assets/Demo/scripts/TweenFlowGUI.cs index 64f4a34..574d945 100644 --- a/Assets/Demo/scripts/TweenFlowGUI.cs +++ b/Assets/Demo/scripts/TweenFlowGUI.cs @@ -30,18 +30,15 @@ void Start() // create a Tween for each cube and add it to the flow var startTime = 0f; - foreach( var cube in cubes ) + for(int i = 0; i < cubes.Length; ++i) { - var tween = new GoTween( cube, 0.5f, config ); - flow.insert( startTime, tween ); - + var cube = cubes[i]; + var tween = new GoTween(cube, 0.5f, config); + flow.insert(startTime, tween); // increment our startTime so that the next tween starts when this one is halfway done startTime += 1.0f; - - - var tweenTwo = new GoTween( cube, 0.5f, config ); - flow.insert( startTime, tweenTwo ); - + var tweenTwo = new GoTween(cube, 0.5f, config); + flow.insert(startTime, tweenTwo); startTime += 0.25f; } diff --git a/Assets/Editor/GoDummyPathEditor.cs b/Assets/Editor/GoDummyPathEditor.cs index c2b4bc6..4043512 100644 --- a/Assets/Editor/GoDummyPathEditor.cs +++ b/Assets/Editor/GoDummyPathEditor.cs @@ -1,7 +1,6 @@ using UnityEngine; using UnityEditor; using System.Collections; -using System.Linq; using System.Collections.Generic; using System.IO; diff --git a/Assets/Plugins/GoKit/Go.cs b/Assets/Plugins/GoKit/Go.cs index 3f2e853..35312f5 100644 --- a/Assets/Plugins/GoKit/Go.cs +++ b/Assets/Plugins/GoKit/Go.cs @@ -371,12 +371,13 @@ public static void removeTweenWithTag( string tag ) List tweenList = tweensWithTag( tag ); if( tweenList != null ) { - foreach( var tween in tweenList ) + for(int i = 0; i < tweenList.Count; ++i) { - removeTween( tween ); + var tween = tweenList[i]; + removeTween(tween); } } - } + } /// /// returns a list of all Tweens, TweenChains and TweenFlows with the given tag @@ -384,13 +385,14 @@ public static void removeTweenWithTag( string tag ) public static List tweensWithTag( string tag ) { List list = null; - foreach( var tween in _tweens ) + for(int i = 0; i < _tweens.Count; ++i) { - if( tween.tag == tag ) + var tween = _tweens[i]; + if(tween.tag == tag) { - if( list == null ) + if(list == null) list = new List(); - list.Add( tween ); + list.Add(tween); } } From 5f0369063a6d7fe4db72e6b26d42c3f77f107219 Mon Sep 17 00:00:00 2001 From: sp-francisco-ruiz Date: Fri, 26 May 2017 08:30:54 +0200 Subject: [PATCH 2/3] Fixed compile error due to deleted char. --- Assets/Demo/scripts/TweenChainGUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Demo/scripts/TweenChainGUI.cs b/Assets/Demo/scripts/TweenChainGUI.cs index 719387d..774bef6 100644 --- a/Assets/Demo/scripts/TweenChainGUI.cs +++ b/Assets/Demo/scripts/TweenChainGUI.cs @@ -29,7 +29,7 @@ void Start() { var cube = cubes[i]; var tween = new GoTween(cube, 0.5f, config); - hain.append(tween); + chain.append(tween); } _tween = chain; From e29a9c97d077817f181392ec5b895bec59904d45 Mon Sep 17 00:00:00 2001 From: sp-francisco-ruiz Date: Fri, 26 May 2017 08:39:49 +0200 Subject: [PATCH 3/3] Adjusted format to follow the project guidelines --- Assets/Demo/scripts/TweenChainGUI.cs | 6 +++--- Assets/Demo/scripts/TweenFlowGUI.cs | 8 ++++---- Assets/Plugins/GoKit/Go.cs | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Assets/Demo/scripts/TweenChainGUI.cs b/Assets/Demo/scripts/TweenChainGUI.cs index 774bef6..aa7e22d 100644 --- a/Assets/Demo/scripts/TweenChainGUI.cs +++ b/Assets/Demo/scripts/TweenChainGUI.cs @@ -25,11 +25,11 @@ void Start() chain.setOnCompleteHandler( c => Debug.Log( "chain complete" ) ); // create a Tween for each cube and it to the chain - for(int i = 0; i < cubes.Length; ++i) + for( int i = 0; i < cubes.Length; ++i ) { var cube = cubes[i]; - var tween = new GoTween(cube, 0.5f, config); - chain.append(tween); + var tween = new GoTween( cube, 0.5f, config ); + chain.append( tween ); } _tween = chain; diff --git a/Assets/Demo/scripts/TweenFlowGUI.cs b/Assets/Demo/scripts/TweenFlowGUI.cs index 574d945..8a5c70a 100644 --- a/Assets/Demo/scripts/TweenFlowGUI.cs +++ b/Assets/Demo/scripts/TweenFlowGUI.cs @@ -30,15 +30,15 @@ void Start() // create a Tween for each cube and add it to the flow var startTime = 0f; - for(int i = 0; i < cubes.Length; ++i) + for( int i = 0; i < cubes.Length; ++i ) { var cube = cubes[i]; var tween = new GoTween(cube, 0.5f, config); - flow.insert(startTime, tween); + flow.insert( startTime, tween ); // increment our startTime so that the next tween starts when this one is halfway done startTime += 1.0f; - var tweenTwo = new GoTween(cube, 0.5f, config); - flow.insert(startTime, tweenTwo); + var tweenTwo = new GoTween( cube, 0.5f, config ); + flow.insert( startTime, tweenTwo ); startTime += 0.25f; } diff --git a/Assets/Plugins/GoKit/Go.cs b/Assets/Plugins/GoKit/Go.cs index 35312f5..1557c23 100644 --- a/Assets/Plugins/GoKit/Go.cs +++ b/Assets/Plugins/GoKit/Go.cs @@ -371,10 +371,10 @@ public static void removeTweenWithTag( string tag ) List tweenList = tweensWithTag( tag ); if( tweenList != null ) { - for(int i = 0; i < tweenList.Count; ++i) + for( int i = 0; i < tweenList.Count; ++i ) { var tween = tweenList[i]; - removeTween(tween); + removeTween( tween ); } } } @@ -385,14 +385,14 @@ public static void removeTweenWithTag( string tag ) public static List tweensWithTag( string tag ) { List list = null; - for(int i = 0; i < _tweens.Count; ++i) + for( int i = 0; i < _tweens.Count; ++i ) { var tween = _tweens[i]; - if(tween.tag == tag) + if( tween.tag == tag ) { - if(list == null) + if( list == null ) list = new List(); - list.Add(tween); + list.Add( tween ); } }