今天的问题是关于团结好吧,我总是刚起步,所以我只是从商店里拿走了全部资产因此,在应用某些更改时,我会遇到一个疯狂的错误,即没有相机渲染在项目开始时,一切顺利这是链接到相机的脚本此脚本只是试图使地图生成器尚未完成
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;
to
x=(int) pos.x;
通过可变平面指向主摄像机的方式
今天的问题是团结一致,我始终处于起步阶段,所以我只是从商店中拿走了全部资产,因此在进行一些更改时,我会遇到一个疯狂的错误,说没有相机...
您最终将相机分配给阵列,并最终将其移动到[0]位置并销毁它