Unity Instantiate GameObject无法在iOS中运行

时间:2015-12-01 04:58:22

标签: ios mobile unity3d game-engine

我有一个级别加载脚本,它从从文件加载的数组表示中绘制一个级别。这在Unity编辑器中运行良好,但是当我为ios构建时,动态绘制的对象不会显示。

以下是执行绘图的代码:

void DrawNewLevel(int level) {
    LevelEditor.Level lvl = new LevelEditor.Level (1, level);
    for (int x = 0; x < 260; x++) {
        for (int y = 0; y < 23; y++) {
            GameObject gameObject;
            if (lvl.LevelContents[x, y].BlockType != LevelEditor.BlockType.Empty) {
                Debug.Log("drawing non-null");
                if (lvl.LevelContents[x, y].BlockType == LevelEditor.BlockType.Floor) {
                    gameObject = Instantiate(Floor);
                    gameObject.transform.position = new Vector3(x, 23-y, 0);
                } else if (lvl.LevelContents[x, y].BlockType == LevelEditor.BlockType.FloorBad) {
                    gameObject = Instantiate(FloorBad);
                    gameObject.transform.position = new Vector3(x, 23-y, 0);
                } else if (lvl.LevelContents[x, y].BlockType == LevelEditor.BlockType.SmartRocketLauncher) {
                    gameObject = Instantiate(SmartRocketLauncher);
                    gameObject.transform.position = new Vector3(x, 23-y, 1);
                }

            }
        }
    }
}

0 个答案:

没有答案