Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlayBoundary : MonoBehaviour {
- public float xMin;
- public float xMax;
- public float yMin;
- public float yMax;
- private Vector3 topLeftCorner;
- private Vector3 topRightCorner;
- private Vector3 bottomLeftCorner;
- private Vector3 bottomRightCorner;
- private void Start ()
- {
- //prevents wrong corner values
- if (xMin > xMax)
- Debug.LogError ("xMin cannot be larger than xMax");
- if (yMin > yMax)
- Debug.LogError ("yMin cannot be larger than yMax");
- }
- private void OnDrawGizmos ()
- {
- //Sets values for each corner of the boundary
- topLeftCorner = new Vector3 (xMin * 1.25f, yMax * 1.25f, 0f);
- topRightCorner = new Vector3 (xMax * 1.25f, yMax * 1.25f, 0f);
- bottomLeftCorner = new Vector3 (xMin * 1.25f, yMin * 1.25f, 0f);
- bottomRightCorner = new Vector3 (xMax * 1.25f, yMin * 1.25f, 0f);
- Gizmos.color = Color.red;
- //Left line
- Gizmos.DrawLine (bottomLeftCorner, topLeftCorner);
- //Top line
- Gizmos.DrawLine (topLeftCorner, topRightCorner);
- //Right line
- Gizmos.DrawLine (bottomRightCorner, topRightCorner);
- //Bottom line
- Gizmos.DrawLine (bottomLeftCorner, bottomRightCorner);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement