【发布时间】:2021-07-18 10:35:14
【问题描述】:
我运行了这段代码。 团结停止了。 1到10分钟后统一关闭 当我删除 Instantiate 时,此代码运行良好! 如何让这段代码运行良好?
Unity Editor.log 文件:https://github.com/Oein/UnityBuilds/blob/main/Editor.log.zip
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MakeGround : MonoBehaviour
{
public Sprite ground;
public Sprite leftGround;
public Sprite rightGround;
string[] map = {
"aaaaaaaaaa",
"aaaaaaaaaa",
"aaaaaaaaaa",
"zxxxxxxxxc"
};
// Start is called before the first frame update
void Awake()
{
for (int y = 0; y < map.Length; y++)
{
for (int x = 0; x < map[0].Length; x++)
{
print(x.ToString() + " At " + y.ToString());
this.transform.position = new Vector3(x, y, 0);
if (map[map.Length - 1 - y][x] != 'a')
{
Instantiate(gameObject , transform);
}
}
}
}
// Update is called once per frame
void Update()
{
}
}
【问题讨论】:
标签: unity3d crash instantiation