// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { PlatformSquare square = hit.collider.GetComponent <PlatformSquare> (); if (square != null) { int typeIndex = FindTypeIndex(square); if (typeIndex == -1) { Debug.Log("Couldn't find matching prefab for clicked on square '" + square.name + "' with type '" + square.GetType()); } else { int nextIndex = (typeIndex + 1 < m_squareTypes.Count ? typeIndex + 1 : 0); m_grid.ReplaceSquare(m_squareTypes [nextIndex], m_squareData [nextIndex], square.GridPosition.x, square.GridPosition.y, new Dictionary <string, string>()); Debug.Log(m_grid.AsLevelDefinition().ToString()); } } } } }