Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [RequireComponent(typeof(Image))]
- class rotation : MonoBehaviour
- {
- [SerializeField]
- private float left = 180f, up = 0f;
- private void OnDrawGizmosSelected()
- {
- RectTransform rect = GetComponent<RectTransform>();
- Vector3[] corners = new Vector3[4];
- rect.GetWorldCorners(corners);
- float rot = transform.eulerAngles.z;
- Gizmos.color = Color.red;
- Gizmos.DrawLine(corners[3], corners[3] +
- new Vector3(Mathf.Cos((left + rot) * Mathf.Deg2Rad) * rect.rect.width,
- Mathf.Sin((left + rot) * Mathf.Deg2Rad) * rect.rect.height));
- Gizmos.color = Color.blue;
- Gizmos.DrawLine(corners[3], corners[3] +
- new Vector3(Mathf.Cos((up + rot) * Mathf.Deg2Rad) * rect.rect.width,
- Mathf.Sin((up + rot) * Mathf.Deg2Rad) * rect.rect.height));
- }
- }
Add Comment
Please, Sign In to add comment