public static void AddPair(Tile t, TileMesh m) { EditorTileMeshContainer container = GetInstance(); if (container.map == null) { Reset(container); } if (_instance.map.ContainsKey(t)) { TileMesh mesh = _instance.map[t]; if (mesh != null) { Destroy(mesh.gameObject); } _instance.map[t] = m; } else { _instance.map.Add(t, m); } m.transform.SetParent(_instance.gameObject.transform); }
public static void Reset(EditorTileMeshContainer container) { if (container == null) { return; } container.map = new Dictionary <Tile, TileMesh>(); container.gameObject.DeleteChildren(); }
public GameObject SpawnMesh(TileMesh child) { float start = Time.realtimeSinceStartup; child.SetTile(this); EditorTileMeshContainer.AddPair(this, child); //MDebug.Log("[SPAWN 1.1] " + (Time.realtimeSinceStartup - start).ToString("0.0000000000")); return(child.gameObject); }
public void SpawnBaseGrid() { _instance = this; EditorTileMeshContainer.Reset(); GridHeight = 0; GridWidth = 0; int cc = transform.childCount; for (int i = cc - 1; i >= 0; i--) { DestroyImmediate(transform.GetChild(i).gameObject); } AppendGrid(SpawnTiles()); }
static EditorTileMeshContainer GetInstance() { if (_instance != null) { return(_instance); } _instance = FindObjectOfType <EditorTileMeshContainer>(); if (_instance != null) { return(_instance); } _instance = new GameObject().AddComponent <EditorTileMeshContainer>(); _instance.name = "Tile Mesh Container"; return(_instance); }