I made a small plane and was going to add a boundary to the plane’s range, and I chose OnDrawGizmos(), but I had a problem.
The problem is that I can’t see the rectangle boundary I drew in my project panel.
This is my code. I put it on the plane. In fact, if I replace this code with some other simple boundary code, I can’t see the boundary too.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoundsCheck : MonoBehaviour
{
[Header("Set Dynamically")]
public float camWidth;
public float camHeight;
private void Awake()
{
camHeight = Camera.main.orthographicSize;
camWidth = camHeight * Camera.main.aspect;
}
private void OnDrawGizmos()
{
if(!Application.isPlaying)
{
return;
}
Vector3 boundSize = new Vector3(camWidth * 2, camHeight * 2, 0.1f);
Gizmos.DrawWireCube(Vector3.zero, boundSize);
}
}
And the Gizmos menu does have this script.
Hope someone can give advice, if there is anything I need to add, please feel free to ask, thanks a million.
