谷歌搜索后,我认为这是一个内存泄漏,但我不知道如何解决这个问题。
断言失败:TLS分配器ALLOC_TEMP_THREAD,底层分配器ALLOC_TEMP_THREAD具有不一致的分配,大小为1528
我正在使用Unity 2018.1.0.0f2。
以下是导致错误的脚本(对不起我糟糕的代码组织技能,对世界一代的新手)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WorldGeneration : MonoBehaviour {
public float GenerationDelay;
public float RoomPicker;
public float LevelNumber;
public float RoomCount;
public float MaxRoomCount;
public float LevelSample1Rooms;
public float MaxLevelSample1Rooms;
public float LevelSample2Rooms;
public float MaxLevelSample2Rooms;
public float LevelSample3Rooms;
public float MaxLevelSample3Rooms;
public float LevelSample4Rooms;
public float MaxLevelSample4Rooms;
public float LevelSample5Rooms;
public float MaxLevelSample5Rooms;
public GameObject LevelSample1;
public GameObject LevelSample2;
public GameObject LevelSample3;
public GameObject LevelSample4;
public GameObject LevelSample5;
public Transform SpawnLevelPoint;
public Transform SpawnLevelPoint1;
public bool Leveloadedatpoint1;
public Transform SpawnLevelPoint2;
public bool Leveloadedatpoint2;
public Transform SpawnLevelPoint3;
public bool Leveloadedatpoint3;
public Transform SpawnLevelPoint4;
public bool Leveloadedatpoint4;
public Transform SpawnLevelPoint5;
public bool Leveloadedatpoint5;
public Transform SpawnLevelPoint6;
public bool Leveloadedatpoint6;
void Start()
{
StartCoroutine("Createpoint1room");
}
public IEnumerator Createpoint1room()
{
if (Leveloadedatpoint1 == false)
{
RoomPicker = Random.Range(1, 20);
yield return new WaitForSeconds(GenerationDelay);
if (RoomPicker == 1 || RoomPicker == 2 || RoomPicker == 3 || RoomPicker == 4 || RoomPicker == 5)
{
if (Leveloadedatpoint1 == false)
{
if (LevelSample1Rooms < MaxLevelSample1Rooms)
{
LevelSample1Rooms += 1;
Instantiate(LevelSample1, SpawnLevelPoint1.transform.position, Quaternion.identity);
Leveloadedatpoint1 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint2room");
}
else
{
StartCoroutine("Createpoint1room");
}
}
else
{
StartCoroutine("Createpoint1room");
}
}
if (RoomPicker == 6 || RoomPicker == 7 || RoomPicker == 8)
{
if (Leveloadedatpoint1 == false)
{
if (LevelSample2Rooms < MaxLevelSample2Rooms)
{
LevelSample2Rooms += 1;
Instantiate(LevelSample2, SpawnLevelPoint1.transform.position, Quaternion.identity);
Leveloadedatpoint1 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint2room");
}
else
{
StartCoroutine("Createpoint1room");
}
}
else
{
StartCoroutine("Createpoint1room");
}
}
if (RoomPicker == 9 || RoomPicker == 10 || RoomPicker == 11)
{
if (Leveloadedatpoint1 == false)
{
if (LevelSample3Rooms < MaxLevelSample3Rooms)
{
LevelSample3Rooms += 1;
Instantiate(LevelSample3, SpawnLevelPoint1.transform.position, Quaternion.identity);
Leveloadedatpoint1 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint2room");
}
else
{
StartCoroutine("Createpoint1room");
}
}
else
{
StartCoroutine("Createpoint1room");
}
}
if (RoomPicker == 12 || RoomPicker == 13 || RoomPicker == 14)
{
if (Leveloadedatpoint1 == false)
{
if (LevelSample4Rooms < MaxLevelSample4Rooms)
{
LevelSample4Rooms += 1;
Instantiate(LevelSample4, SpawnLevelPoint1.transform.position, Quaternion.identity);
Leveloadedatpoint1 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint2room");
}
else
{
StartCoroutine("Createpoint1room");
}
}
else
{
StartCoroutine("Createpoint1room");
}
}
if (RoomPicker == 15 || RoomPicker == 16 || RoomPicker == 17)
{
if (Leveloadedatpoint1 == false)
{
if (LevelSample5Rooms < MaxLevelSample5Rooms)
{
LevelSample5Rooms += 1;
Instantiate(LevelSample5, SpawnLevelPoint1.transform.position, Quaternion.identity);
Leveloadedatpoint1 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint2room");
}
else
{
StartCoroutine("Createpoint1room");
}
}
else
{
StartCoroutine("Createpoint1room");
}
}
if (RoomPicker == 18 || RoomPicker == 19 || RoomPicker == 20)
{
StartCoroutine("Createpoint1room");
}
Debug.Log("Point 1: The number is " + RoomPicker);
}
else
{
StartCoroutine("Createpoint2room");
}
}
public IEnumerator Createpoint2room()
{
if (Leveloadedatpoint2 == false)
{
RoomPicker = Random.Range(1, 20);
yield return new WaitForSeconds(GenerationDelay);
if (RoomPicker == 1 || RoomPicker == 2 || RoomPicker == 3 || RoomPicker == 4 || RoomPicker == 5)
{
if (Leveloadedatpoint2 == false)
{
if (LevelSample1Rooms < MaxLevelSample1Rooms)
{
LevelSample1Rooms += 1;
Instantiate(LevelSample1, SpawnLevelPoint2.transform.position, Quaternion.identity);
Leveloadedatpoint2 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint3room");
}
else
{
StartCoroutine("Createpoint2room");
}
}
else
{
StartCoroutine("Createpoint2room");
}
}
if (RoomPicker == 6 || RoomPicker == 7 || RoomPicker == 8)
{
if (Leveloadedatpoint2 == false)
{
if (LevelSample2Rooms < MaxLevelSample2Rooms)
{
LevelSample2Rooms += 1;
Instantiate(LevelSample2, SpawnLevelPoint2.transform.position, Quaternion.identity);
Leveloadedatpoint2 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint3room");
}
else
{
StartCoroutine("Createpoint2room");
}
}
else
{
StartCoroutine("Createpoint2room");
}
}
if (RoomPicker == 9 || RoomPicker == 10 || RoomPicker == 11)
{
if (Leveloadedatpoint2 == false)
{
if (LevelSample3Rooms < MaxLevelSample3Rooms)
{
LevelSample3Rooms += 1;
Instantiate(LevelSample3, SpawnLevelPoint2.transform.position, Quaternion.identity);
Leveloadedatpoint2 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint3room");
}
else
{
StartCoroutine("Createpoint2room");
}
}
else
{
StartCoroutine("Createpoint2room");
}
}
if (RoomPicker == 12 || RoomPicker == 13 || RoomPicker == 14)
{
if (Leveloadedatpoint2 == false)
{
if (LevelSample4Rooms < MaxLevelSample4Rooms)
{
LevelSample4Rooms += 1;
Instantiate(LevelSample4, SpawnLevelPoint2.transform.position, Quaternion.identity);
Leveloadedatpoint2 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint3room");
}
else
{
StartCoroutine("Createpoint2room");
}
}
else
{
StartCoroutine("Createpoint2room");
}
}
if (RoomPicker == 15 || RoomPicker == 16 || RoomPicker == 17)
{
if (Leveloadedatpoint2 == false)
{
if (LevelSample5Rooms < MaxLevelSample5Rooms)
{
LevelSample5Rooms += 1;
Instantiate(LevelSample5, SpawnLevelPoint2.transform.position, Quaternion.identity);
Leveloadedatpoint2 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint3room");
}
else
{
StartCoroutine("Createpoint2room");
}
}
else
{
StartCoroutine("Createpoint2room");
}
}
if (RoomPicker == 18 || RoomPicker == 19 || RoomPicker == 20)
{
StartCoroutine("Createpoint2room");
}
Debug.Log("Point 2: The number is " + RoomPicker);
}
else
{
StartCoroutine("Createpoint3room");
}
}
public IEnumerator Createpoint3room()
{
if (Leveloadedatpoint3 == false)
{
RoomPicker = Random.Range(1, 20);
yield return new WaitForSeconds(GenerationDelay);
if (RoomPicker == 1 || RoomPicker == 2 || RoomPicker == 3 || RoomPicker == 4 || RoomPicker == 5)
{
if (Leveloadedatpoint3 == false)
{
if (LevelSample1Rooms < MaxLevelSample1Rooms)
{
LevelSample1Rooms += 1;
Instantiate(LevelSample1, SpawnLevelPoint3.transform.position, Quaternion.identity);
Leveloadedatpoint3 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint4room");
}
else
{
StartCoroutine("Createpoint3room");
}
}
else
{
StartCoroutine("Createpoint3room");
}
}
if (RoomPicker == 6 || RoomPicker == 7 || RoomPicker == 8)
{
if (Leveloadedatpoint3 == false)
{
if (LevelSample2Rooms < MaxLevelSample2Rooms)
{
LevelSample2Rooms += 1;
Instantiate(LevelSample2, SpawnLevelPoint3.transform.position, Quaternion.identity);
Leveloadedatpoint3 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint4room");
}
else
{
StartCoroutine("Createpoint3room");
}
}
else
{
StartCoroutine("Createpoint3room");
}
}
if (RoomPicker == 9 || RoomPicker == 10 || RoomPicker == 11)
{
if (Leveloadedatpoint3 == false)
{
if (LevelSample3Rooms < MaxLevelSample3Rooms)
{
LevelSample3Rooms += 1;
Instantiate(LevelSample3, SpawnLevelPoint3.transform.position, Quaternion.identity);
Leveloadedatpoint3 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint4room");
}
else
{
StartCoroutine("Createpoint3room");
}
}
else
{
StartCoroutine("Createpoint3room");
}
}
if (RoomPicker == 12 || RoomPicker == 13 || RoomPicker == 14)
{
if (Leveloadedatpoint3 == false)
{
if (LevelSample4Rooms < MaxLevelSample4Rooms)
{
LevelSample4Rooms += 1;
Instantiate(LevelSample4, SpawnLevelPoint3.transform.position, Quaternion.identity);
Leveloadedatpoint3 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint4room");
}
else
{
StartCoroutine("Createpoint3room");
}
}
else
{
StartCoroutine("Createpoint3room");
}
}
if (RoomPicker == 15 || RoomPicker == 16 || RoomPicker == 17)
{
if (Leveloadedatpoint3 == false)
{
if (LevelSample5Rooms < MaxLevelSample5Rooms)
{
LevelSample5Rooms += 1;
Instantiate(LevelSample5, SpawnLevelPoint3.transform.position, Quaternion.identity);
Leveloadedatpoint3 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint4room");
}
else
{
StartCoroutine("Createpoint3room");
}
}
else
{
StartCoroutine("Createpoint3room");
}
}
if (RoomPicker == 18 || RoomPicker == 19 || RoomPicker == 20)
{
StartCoroutine("Createpoint3room");
}
Debug.Log("Point 3: The number is " + RoomPicker);
}
else
{
StartCoroutine("Createpoint4room");
}
}
public IEnumerator Createpoint4room()
{
if (Leveloadedatpoint4 == false)
{
RoomPicker = Random.Range(1, 20);
yield return new WaitForSeconds(GenerationDelay);
if (RoomPicker == 1 || RoomPicker == 2 || RoomPicker == 3 || RoomPicker == 4 || RoomPicker == 5)
{
if (Leveloadedatpoint4 == false)
{
if (LevelSample1Rooms < MaxLevelSample1Rooms)
{
LevelSample1Rooms += 1;
Instantiate(LevelSample1, SpawnLevelPoint4.transform.position, Quaternion.identity);
Leveloadedatpoint4 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint5room");
}
else
{
StartCoroutine("Createpoint4room");
}
}
else
{
StartCoroutine("Createpoint4room");
}
}
if (RoomPicker == 6 || RoomPicker == 7 || RoomPicker == 8)
{
if (Leveloadedatpoint4 == false)
{
if (LevelSample2Rooms < MaxLevelSample2Rooms)
{
LevelSample2Rooms += 1;
Instantiate(LevelSample2, SpawnLevelPoint4.transform.position, Quaternion.identity);
Leveloadedatpoint4 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint5room");
}
else
{
StartCoroutine("Createpoint4room");
}
}
else
{
StartCoroutine("Createpoint4room");
}
}
if (RoomPicker == 9 || RoomPicker == 10 || RoomPicker == 11)
{
if (Leveloadedatpoint4 == false)
{
if (LevelSample3Rooms < MaxLevelSample3Rooms)
{
LevelSample3Rooms += 1;
Instantiate(LevelSample3, SpawnLevelPoint4.transform.position, Quaternion.identity);
Leveloadedatpoint4 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint5room");
}
else
{
StartCoroutine("Createpoint4room");
}
}
else
{
StartCoroutine("Createpoint4room");
}
}
if (RoomPicker == 12 || RoomPicker == 13 || RoomPicker == 14)
{
if (Leveloadedatpoint4 == false)
{
if (LevelSample4Rooms < MaxLevelSample4Rooms)
{
LevelSample4Rooms += 1;
Instantiate(LevelSample4, SpawnLevelPoint4.transform.position, Quaternion.identity);
Leveloadedatpoint3 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint4room");
}
else
{
StartCoroutine("Createpoint4room");
}
}
else
{
StartCoroutine("Createpoint4room");
}
}
if (RoomPicker == 15 || RoomPicker == 16 || RoomPicker == 17)
{
if (Leveloadedatpoint3 == false)
{
if (LevelSample5Rooms < MaxLevelSample5Rooms)
{
LevelSample5Rooms += 1;
Instantiate(LevelSample5, SpawnLevelPoint4.transform.position, Quaternion.identity);
Leveloadedatpoint3 = true;
yield return new WaitForSeconds(GenerationDelay);
StartCoroutine("Createpoint5room");
}
else
{
StartCoroutine("Createpoint4room");
}
}
else
{
StartCoroutine("Createpoint4room");
}
}
if (RoomPicker == 18 || RoomPicker == 19 || RoomPicker == 20)
{
StartCoroutine("Createpoint4room");
}
Debug.Log("Point 4: The number is " + RoomPicker);
}
else
{
StartCoroutine("Createpoint4room");
}
}
public IEnumerator Createpoint5room()
{
yield return new WaitForSeconds(GenerationDelay);
Debug.Log("Generation finished");
}
}
EDIT1: 这个错误似乎也让我的编辑器崩溃并且崩溃了游戏的构建。
答案 0 :(得分:0)
我的结论是,这只是因为硬件规格。
答案 1 :(得分:0)
我收到了Stack allocator ALLOC_TEMP_THREAD has unfreed allocations, size ...
条消息。收到的消息几乎相同,但不完全相同,但这可能是由于Unity版本不同(我在2018.2.9版)。
但是正如here所述,只需重启Unity即可为我修复。