Hello !
Here’s the issue:
I got a simple class named Room
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Room : MonoBehaviour {
public int PosX;
public int PosY;
//don't mind the next variables
public bool HasBeenAdded = false;
public List<Room> listeRoomsLinked = new List<Room>();
public bool IsEntree = false;
public bool IsSortie = false;
public int NUMERO = 99;
public Room(int _x, int _y)
{
PosX = _x;
PosY = _y;
}
...
and a 2nd class Named GenerateFloor
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GenerateFloor : MonoBehaviour {
int WidthMap;
int HeightMap;
Room[,] TableauRooms;
void Awake()
{
GenerateTheFloor ();
DrawMap ();
}
public void GenerateTheFloor()
{
WidthMap = 4;
HeightMap = 3;
//Initialize Array[,]
TableauRooms = new Room[WidthMap , HeightMap];
//Fill the table with Room Objects
for (int i = 0; i < WidthMap ; i++)
for (int j = 0; j < HeightMap ; j++) {
TableauRooms[i, j] = new Room (i,j);
}
Room _room = TableauRooms [2, 2];
...
And now
you can see I get null value
But the array[,] has objects in it
What am I doing wrong ?
Thanks for reading