Я изучаю Unity C #, я делал урок от Unity, 2d roguelike, мы пытаемся создать экземпляр плитки для пола, я сделал то же самое, что и в видео (на самом деле я даже скопировал код), но он показывает мне ошибка на линии
GameObject instance = Instantiate(toInstantiate, new Vector3(x, y, 0f),
Quaternion.identity) as GameObject;
специально с Instantiate(toInstantiate)
.
Вы можете мне помочь?
using UnityEngine;
using System;
using System.Collections.Generic;
using Random = UnityEngine.Random;
public class BoardManager : MonoBehaviour
{
// Other class code omitted
void BoardSetup()
{
boardHolder = new GameObject("Board").transform;
for (int x = -1; x < columns + 1; x++)
{
for (int y = -1; y < rows + 1; y++)
{
GameObject toInstantiate = floorTiles[Random.Range(0, floorTiles.Length)];
if (x == -1 || x == columns || y == -1 || y == rows)
toInstantiate = outerWallTiles[Random.Range(0, outerWallTiles.Length)];
GameObject instance = Instantiate(toInstantiate, new Vector3(x, y, 0f),
Quaternion.identity) as GameObject;
instance.transform.SetParent(boardHolder);
}
}
}
}