static public void CreateArray()
{
CacheSortingLayers();
List <GameObject> GameObjects = new List <GameObject>();
Self.m_TilemapSize = new IntVector2(0, 0);
GameObjects.AddRange(GameObject.FindGameObjectsWithTag("GameTile").OrderBy(gameObject => GetSortingLayerOrder(gameObject.GetComponent <SpriteRenderer>().sortingLayerName)).ToList());
int LowestX = 0, HighestX = 0;
int LowestY = 0, HighestY = 0;
foreach (GameObject gameObject in GameObjects)
{
Vector3 <int> ObjectGridPosition = new Vector3 <int>((int)GetGridPosition(gameObject.transform.position).x, (int)GetGridPosition(gameObject.transform.position).y, 0);
if (ObjectGridPosition.x < LowestX)
{
LowestX = ObjectGridPosition.x;
}
if (ObjectGridPosition.x > HighestX)
{
HighestX = ObjectGridPosition.x;
}
if (ObjectGridPosition.y < LowestY)
{
LowestY = ObjectGridPosition.y;
}
if (ObjectGridPosition.y > HighestY)
{
HighestY = ObjectGridPosition.y;
}
}
Self.m_TilemapOffset = new IntVector2(LowestX, LowestY);
Self.m_TilemapSize = new IntVector2(Math.Abs(HighestX - LowestX) + 1, Math.Abs(HighestY - LowestY) + 1);
Self.m_Tiles = new Dictionary <string, List <GameObject> >();
foreach (GameObject gameObject in GameObjects)
{
IntVector2 ArrayIndex = GetArrayIndex(gameObject);
if (!Self.m_Tiles.ContainsKey(ArrayIndex.ToString()))
{
Self.m_Tiles[ArrayIndex.ToString()] = new List <GameObject>();
}
Self.m_Tiles[ArrayIndex.ToString()].Add(gameObject);
}
}