Skip to content

Instantly share code, notes, and snippets.

@ryedin
Created October 23, 2013 21:51
Show Gist options
  • Save ryedin/7127439 to your computer and use it in GitHub Desktop.
Save ryedin/7127439 to your computer and use it in GitHub Desktop.
detecting gallery direction changes
float current = 0;
if( isHorizontal ) current = transform.localPosition.x;
else current = -transform.localPosition.y;
float max = 0;
if( isHorizontal ) max = CellWidth+Spacing;
else max = CellHeight+Spacing;
//detect left/right direction changes
if (current < _last) {
Debug.Log("Moving Left");
if (currentDirection != direction.Left) {
Debug.Log("CHANGED DIRECTION TO THE LEFT");
currentDirection = direction.Left;
}
} else if (current > _last) {
Debug.Log("Moving Right");
if (currentDirection != direction.Right) {
Debug.Log("CHANGED DIRECTION TO THE RIGHT");
currentDirection = direction.Right;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment