Last active
August 29, 2015 13:56
-
-
Save nicloay/9326636 to your computer and use it in GitHub Desktop.
rotate around pivot issue
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
// enstead of this | |
GUIUtility.RotateAroundPivot(angle, | |
new Vector2(brushRect.x + brushRect.width * relativePivot.x, | |
brushRect.y + brushRect.height * relativePivot.y) | |
); | |
/////// should use | |
Matrix4x4 getMatrix(Rect rect){ | |
Matrix4x4 result; | |
Vector2 v =new Vector2(rect.x + (rect.width * relativePivot.x) , | |
rect.y + (rect.height * relativePivot.y)) ; | |
float scaleX = Screen.width / (float) GameData.instance.screenSize.x; | |
float scaleY = Screen.height / (float) GameData.instance.screenSize.y; | |
result =Matrix4x4.Scale(new Vector3(scaleX, scaleY, 1)) | |
* Matrix4x4.TRS ( v, Quaternion.Euler(0,0,angle) , Vector3.one) | |
* Matrix4x4.TRS (-v, Quaternion.identity , Vector3.one); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment