每次我运行程序时团结崩溃。在找到崩溃报告后,它说(文件名:Assets / SkySpawner.cs行:60) 无法从异常中提取异常字符串(在处理堆栈跟踪时抛出类' NullReferenceException'的另一个例外)
这是似乎不喜欢的代码
IEnumerator EnemyGenerator()
{
if (actives)
{
var newTransform = transform;
if (!first)
yield return new WaitForSeconds(delay);
if (targets.Count > 0)
{
var spawnTarget = targets[Random.Range(0, targets.Count)];
newTransform = spawnTarget.transform;
direction = spawnTarget.transform.localScale;
}
GameObject clone = Instantiate(enemyPool[Random.Range(0, enemyPool.Length)], new Vector3(0,-6,2), Quaternion.identity) as GameObject;
clone.transform.localScale = direction;
StartCoroutine(EnemyGenerator());
}
}
我有最新版本的Unity(4.5.3)