Created
October 23, 2013 21:51
-
-
Save ryedin/7127439 to your computer and use it in GitHub Desktop.
detecting gallery direction changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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