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

Creating Rule Tiles in Code?

Discussion in '2D' started by Snailtan, Feb 15, 2021.

  1. Snailtan

    Snailtan

    Joined:
    Nov 14, 2017
    Posts:
    2
    Hi!
    I am currently trying to make my game moddable through xml and wanted to be able to make custom tiles.
    I managed to get simple tiles using textures working, but now I want to make rule tiles aswell.
    Anyone know a place where I can read up on how to do this?
    I know it is possible, as there are many tileset editors out there that do it.

    Something where I only have an imput texture, and the code automagically translates it into a rule tile, so I only need to save the location of the png in xml.

    Any help is appreciated
     
  2. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    nothing is automagical until you code it, you have to code 1 ruletile first and configure all rules, only after that can you use createinstance() to duplicate that tile and apply the new texture
     
  3. Snailtan

    Snailtan

    Joined:
    Nov 14, 2017
    Posts:
    2
    Yeah I get that, but how do I code a rule Tile? Thats what I am asking haha
     
  4. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
  5. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    This could be quite complicated. The steps should be as follows:
    • Create a RuleTile using
      ScriptableObject.CreateInstance<RuleTile>()
      .
    • Fill in
      ruleTile.m_TilingRules
      with your Rules