Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor foreach loops into for loops #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Assets/Demo/scripts/TweenChainGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ 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 cube = cubes[i];
var tween = new GoTween( cube, 0.5f, config );
chain.append( tween );
}
Expand Down
9 changes: 3 additions & 6 deletions Assets/Demo/scripts/TweenFlowGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
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 );

startTime += 0.25f;
}

Expand Down
1 change: 0 additions & 1 deletion Assets/Editor/GoDummyPathEditor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using System.IO;

Expand Down
8 changes: 5 additions & 3 deletions Assets/Plugins/GoKit/Go.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,23 @@ public static void removeTweenWithTag( string tag )
List<AbstractGoTween> tweenList = tweensWithTag( tag );
if( tweenList != null )
{
foreach( var tween in tweenList )
for( int i = 0; i < tweenList.Count; ++i )
{
var tween = tweenList[i];
removeTween( tween );
}
}
}
}

/// <summary>
/// returns a list of all Tweens, TweenChains and TweenFlows with the given tag
/// </summary>
public static List<AbstractGoTween> tweensWithTag( string tag )
{
List<AbstractGoTween> list = null;
foreach( var tween in _tweens )
for( int i = 0; i < _tweens.Count; ++i )
{
var tween = _tweens[i];
if( tween.tag == tag )
{
if( list == null )
Expand Down