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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question inner bevel inside a non-rectangular grid

Discussion in 'Scripting' started by julien83franceschi, Sep 11, 2023.

  1. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    192
    Hello everyone,

    My question is rather difficult, which is why I'm asking it.

    I hope you can help me.

    My question is this:
    how to create a 7 pixel wide inner bevel inside a non-rectangular grid.

    See image below:



    Thanks in advance for your help,

    A+
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,160
    Can easily be done with a tile map and a rule tile.
     
    Bunny83 likes this.
  3. ijmmai

    ijmmai

    Joined:
    Jun 9, 2023
    Posts:
    188
    You have been working on this grid, gridlines, grid with holes, and so on for a while already, and got a lot of support/advice/help. I did notice you don't follow up on those threads, did you use any of the suggestions?
     
    Kurt-Dekker and MelvMay like this.
  4. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    192
    Can you help me to use TimeLaps.

    How to cut my grid into small squares.

    How to create more than 100 grids using TimeLaps (maybe with some code).

    I want to create a non-rectangular grid.

    Your advice is welcome,

    A+
     
  5. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,160
    There's a million tutorials out there on how to use tile maps. They're pretty simple.

    Then rule tiles are just tiles that change what sprite they use based on conditions: https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@4.0/manual/RuleTile.html

    And you can of course set the tiles with code via the tile map API: https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.html

    Then it's just a matter of having a data structure to represent what cells have a tile - could literally be a single array of boolean values - and then generating a display based on this data.
     
  6. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    192
    I thought this tutorial was pretty good:


    If I've understood correctly, I need to cut rectangles that contain the bottom and outside corners of the grid (in the example above there are only the inside corners) as well as the top, bottom, left and right edges.

    I then place them in the scene.

    My question is: how do I save the finished grid?

    I'm asking because I need to create 100 grids.

    Thanks for your help,

    A+
     
    Last edited: Sep 13, 2023
  7. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,160
    Well, if you wanted 100 of these, you wouldn't want to design them in a scene. Like I already mentioned, you would need a data structure to represent these layouts. Such as a scriptable object with an array of booleans, and a height and width field.

    And then a rule tile can automatically handle placing the correct tile based on surrounding tiles.
     
  8. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    192
    Hi everyone,

    I've started Tile mapping, I did as they say in the tutorial in the post above.
    I import my image with 32x32 tiles,
    I change the values of my image options (Texture Type: Sprite 2D and UI)...
    I do an apply and open the image editor.
    I make a slice, then nothing, I do an apply again but this time in the image editor, but nothing happens.

    In fact, the software doesn't calculate all the tiles and cut them into small thumbnails (in the project panel).
    You can see that the magnetic grid is shifted by a few pixels (in the Editor sprite).
    However, I did put my tiles in a 32x32 grid.

    If anyone can tell me how to adjust the grid to my tiles.



    Thanks for your help,

    A+
     
    Last edited: Sep 20, 2023
  9. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    192
    I managed to recover the images divided into thumbnails.
    I placed them in the 'Tile palette' and saved them to the hard disk.
    The problem is that I can't use the 'Tile palette' toolbar.
    When I click on a toolbar button and select one or more tiles to move them, Unity creates a selection rectangle, and the tile doesn't move or drag in the scene.
    Please note that I don't have a grid in the Scene tab.
    I also don't understand why there are red-pink tiles. And you can't delete them with the Delete key.

    Here's my image (you can see the blue grid cut into tiles):



    Your help is welcome,

    A+
     
    Last edited: Sep 23, 2023
  10. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,160
    You need a tile map + grid in the scene for your tile pallete to be useful.