-
-
Save toxicFork/2d56a76fde9448023ac1 to your computer and use it in GitHub Desktop.
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
public static Vector2 GetPivotValue(SpriteAlignment alignment, Vector2 customOffset) | |
{ | |
switch (alignment) | |
{ | |
case SpriteAlignment.Center: | |
return new Vector2(0.5f, 0.5f); | |
case SpriteAlignment.TopLeft: | |
return new Vector2(0.0f, 1f); | |
case SpriteAlignment.TopCenter: | |
return new Vector2(0.5f, 1f); | |
case SpriteAlignment.TopRight: | |
return new Vector2(1f, 1f); | |
case SpriteAlignment.LeftCenter: | |
return new Vector2(0.0f, 0.5f); | |
case SpriteAlignment.RightCenter: | |
return new Vector2(1f, 0.5f); | |
case SpriteAlignment.BottomLeft: | |
return new Vector2(0.0f, 0.0f); | |
case SpriteAlignment.BottomCenter: | |
return new Vector2(0.5f, 0.0f); | |
case SpriteAlignment.BottomRight: | |
return new Vector2(1f, 0.0f); | |
case SpriteAlignment.Custom: | |
return customOffset; | |
default: | |
return Vector2.zero; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment