Guest User

Untitled

a guest
Nov 22nd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. [RequireComponent(typeof(Image))]
  2. class rotation : MonoBehaviour
  3. {
  4. [SerializeField]
  5. private float left = 180f, up = 0f;
  6.  
  7. private void OnDrawGizmosSelected()
  8. {
  9. RectTransform rect = GetComponent<RectTransform>();
  10.  
  11. Vector3[] corners = new Vector3[4];
  12. rect.GetWorldCorners(corners);
  13. float rot = transform.eulerAngles.z;
  14.  
  15. Gizmos.color = Color.red;
  16. Gizmos.DrawLine(corners[3], corners[3] +
  17. new Vector3(Mathf.Cos((left + rot) * Mathf.Deg2Rad) * rect.rect.width,
  18. Mathf.Sin((left + rot) * Mathf.Deg2Rad) * rect.rect.height));
  19.  
  20. Gizmos.color = Color.blue;
  21. Gizmos.DrawLine(corners[3], corners[3] +
  22. new Vector3(Mathf.Cos((up + rot) * Mathf.Deg2Rad) * rect.rect.width,
  23. Mathf.Sin((up + rot) * Mathf.Deg2Rad) * rect.rect.height));
  24. }
  25. }
Add Comment
Please, Sign In to add comment