using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapGenerater : MonoBehaviour
{
public GameObject tilePrefab;
public Vector2 mapSize;//public float mapSizeX, mapSizeY;
public Transform mapHolder;
[Range(0,1)] public float outlinePercent;//调整缝隙
private void Start()
{
GenerateMap();
}
private void GenerateMap()
{
for (int i = 0; i < mapSize.x; i++)
{
for (int j = 0; j < mapSize.y; j++)
{
Vector3 newPos = new Vector3(-mapSize.x / 2 + 0.5f + i, 0, -mapSize.y / 2 + 0.5f + j);
GameObject spwanTile=Instantiate(tilePrefab,newPos,Quaternion.Euler(90,0,0));
spwanTile.transform.SetParent(mapHolder);
spwanTile.transform.localScale *= (1 - outlinePercent);
}
}
}
void Update()
{
}
}
这个是我写的代码的部分,是照别的视频里面完全一样抄下来的(介于是学习阶段),但是我这个代码运行的时候就有编译错误