首页 > 解决方案 > 访问数组中的变量?

问题描述

我在这里有这个小块,但我想知道是否可以使用GetTile()数组中的特定变量。

编辑:我的整个脚本是:

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

public class walltilemap : MonoBehaviour
{
    public TileBase Ground_tiles_3;
    public Vector2Int size;
    void Start(){
        Vector3Int[] positions = new Vector3Int[size.x * size.y];
        TileBase[] tileArray = new TileBase[positions.Length];

        for (int index = 0; index < positions.Length; index++){
            positions[index] = new Vector3Int(index % size.x, index / size.y, 0);
            bool iswalltile() {
                if (Tilemap.GetTile(positions[index])){

                }
                return true;
            }
            
            tileArray[index] = iswalltile() == true ? Ground_tiles_3 : null;
        }
        Tilemap WallTileMap = GetComponent<Tilemap>();
        WallTileMap.SetTiles(positions, tileArray);
    }
}

标签: c#unity3d

解决方案


推荐阅读