Unity 2018.3.1f1を使い始めた初心者です。
シーンに配置した二つのカメラ"MainCamera"と"SubCamera"をButtonで"MainCamera"から"SubCamera"へ切り替わるようにしたいのですが
NullReferenceException: Object reference not set to an instance of an object
のエラーが出てしまいます。
使用しているスクリプトは以下のものです。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class switchcamera : MonoBehaviour {
Camera mainCamera;
Camera subCamera;
public switchcamera()
{
}
void start(){
mainCamera = GameObject.Find("MainCamera").GetComponent<Camera>();
subCamera = GameObject.Find("SubCamera").GetComponent<Camera>();
subCamera.enabled = false;
mainCamera.enabled = true;
}
public void OnClick() {
mainCamera.enabled = false;
subCamera.enabled = true;
}
}
findがうまくいっていないのかと思っています。
どなたか、ご教授お願いいたします。