using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Camera))]
public class CameraFrustumGizmo : MonoBehaviour
{
Camera _camera;
void Start()
{
_camera = GetComponent<Camera>();
}
The Camera is black and when i start to type Ca...there is no Camera. I'm not getting errors when compiling the script but when running the game i'm getting null exception.
The script is attached to Main Camera.
I tried now this:
using UnityEngine;
using System.Collections;
public class CameraTest : MonoBehaviour {
Camera _camera;
void Start()
{
_camera = GetComponent<Camera>();
}
public virtual void OnDrawGizmos()
{
Matrix4x4 temp = Gizmos.matrix;
Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
if (_camera.orthographic)
Now the Camera exist but once i attached the script to the Main Camera i'm getting null exception before even running the game the null is on the line:
if (_camera.orthographic)
NullReferenceException: Object reference not set to an instance of an object CameraTest.OnDrawGizmos () (at Assets/MyScripts/CameraTest.cs:17) UnityEditor.DockArea:OnGUI()