Структура Unity сериализуется, но не редактируется из меню компонентов

У меня есть структура в Unity, которая объявлена ​​так:

[System.Serializable]
public struct IntVector2 {
    public int x, z;

    public IntVector2 (int x, int z) {
        this.x = x;
        this.z = z;
    }
    public static IntVector2 operator + (IntVector2 a, IntVector2 b) {
        a.x += b.x;
        a.z += b.z;
        return a;
    }
}

Затем я добавил IntVector2 как поле в скрипте. Когда я посмотрел на компонент script на боковой панели, структуру и ее переменные нигде не было видно. Что я делаю неправильно? РЕДАКТИРОВАТЬ: Вот код моего сценария:

using UnityEngine;
using System.Collections;

public class Maze : MonoBehaviour {
public IntVector2 size;

public MazeCell cellPrefab;

private MazeCell[,] cells;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
public MazeCell GetCell (IntVector2 coordinates) {
    return cells[coordinates.x, coordinates.z];
}
public float generationStepDelay;
public IEnumerator Generate () {
    WaitForSeconds delay = new WaitForSeconds(generationStepDelay);
    cells = new MazeCell[size.x, size.z];
    IntVector2 coordinates = RandomCoordinates;
    while (ContainsCoordinates(coordinates) && GetCell(coordinates) = null) {
        yield return delay;
        CreateCell(coordinates);
        coordinates += MazeDirections.RandomValue.ToIntVector2();
    }
}

private void CreateCell (IntVector2 coordinates) {
    MazeCell newCell = Instantiate(cellPrefab) as MazeCell;
    cells[coordinates.x, coordinates.z] = newCell;
    newCell.name = "Maze Cell " + coordinates.x + ", " + coordinates.z;
    newCell.coordinates = coordinates;
    newCell.transform.parent = transform;
    newCell.transform.localPosition = new Vector3(coordinates.x - size.x * 0.5f + 0.5f, 0f, coordinates.z - size.z * 0.5f + 0.5f);
}

public IntVector2 RandomCoordinates {
    get {
        return new IntVector2(Random.Range(0, size.x), Random.Range(0,       size.z));
    }
}

public bool ContainsCoordinates (IntVector2 coordinate) {
    return coordinate.x >= 0 && coordinate.x < size.x && coordinate.z  >= 0 && coordinate.z < size.z;
}
}

Тот, который не показан size

0 ответов

Другие вопросы по тегам