删除相机后无法渲染

can not render after camera deleted

今天的问题是关于团结 好吧,我总是从头开始,所以我刚从商店拿走了全部资产 所以在应用一些更改时我只是得到一个疯狂的错误说没有相机渲染 在项目开始时一切顺利 这是链接到相机的脚本 此脚本只是试图制作尚未完成的地图生成器

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MapGen : MonoBehaviour
{   
    public GameObject[] flats=new GameObject[4];
    public GameObject flat;
    public int x; 
    // Start is called before the first frame update
    void Start()
    {    
    }

    // Update is called once per frame
    void Update()
    { 
        Vector3 pos = flat.transform.position;

        x = pos.x; 
        Debug.Log("position :: "+ x ); 

        if(x%26 == 0)
        { 
            Destroy(flats[0]);

            for(int i = 0; i < 3; i++)
            {
                flats[i] = flats[i + 1];
            }

            flats[3] = flat; 

            Debug.Log("position "+x);       
        }
    }
}

一切都很好,但尝试这个时

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MapGen : MonoBehaviour
{   
    public GameObject[] flats=new GameObject[4];
    public GameObject flat;
    public int x; 
    // Start is called before the first frame update
    void Start()
    {   
    }

    // Update is called once per frame
    void Update()
    { 
        Vector3 pos = flat.transform.position ;
        x=(int) pos.x; 
        Debug.Log("position :: "+ x ); 

        if(x%26 == 0)
        { 
            Destroy(flats[0]);

            for(int i = 0; i < 3; i++)
            {
               flats[i] = flats[i + 1];
            } 

            flats[3] = flat; 
            Debug.Log("position "+x);       
        }
    }
}

它只是在 运行 游戏之后给我错误,就像相机被摧毁一样,正如你所看到的,只是这个表达式被改变了

x=pos.x; 

x=(int) pos.x;

顺便说一下,变量 flat 指的是主摄像头

你最终将你的相机分配给阵列并最终将它移动到 [0] 位置并销毁它

flats[3] = flat;

flats[i] = flats[i + 1];

Destroy(flats[0]);