Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Tiles Matrix

Discussion in '2D' started by gtarnowskiweb, Mar 15, 2020.

  1. gtarnowskiweb

    gtarnowskiweb

    Joined:
    Aug 16, 2018
    Posts:
    9
    Hello,
    I'm lookings for solution like this:

    Those squares are a simulation of building sizes - based on iso-grid. The main goal is to have squares that inform about possible places to build. Its classical RTS building system. I know how to override/replace tile but i need values that will be dynamically changed I mean (x,y). Presented squares are grid like: 1x1, 2x2, 3x3, 4x4...but I want to generate squares like 10x10. How to do that?
     

    Attached Files:

  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    Maybe I misunderstand, but you can iterate the cells within an area like so:
    Code (CSharp):
    1.         // a 10x10 area starting at position (20, 20)
    2.         RectInt area = new RectInt(20, 20, 10, 10);
    3.         foreach (Vector2Int cell in area.allPositionsWithin)
    4.         {
    5.             Debug.Log((Vector3Int)cell);
    6.         }
     
    gtarnowskiweb likes this.
  3. gtarnowskiweb

    gtarnowskiweb

    Joined:
    Aug 16, 2018
    Posts:
    9
    Yes!! This is it. Thank you a lot