Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Assign the sprite in the Tiling Rules of a RuleTile to a prefab's SpriteRenderer

Discussion in '2D' started by Palineto, Oct 5, 2021.

  1. Palineto

    Palineto

    Joined:
    Dec 5, 2014
    Posts:
    4
    upload_2021-10-5_0-15-46.png

    I had a hard time figuring out how to properly change the sprite of a prefab inside a RuleTile, and thought that it would be a nice feature to add to the RuleTile class.

    For those wondering what I did, I overrode the StartUp method inside the RuleTile class and added this line:

    Code (CSharp):
    1. instantiatedGameObject.GetComponent<SpriteRenderer>().sprite = rule.m_Sprites[0];
     

    Attached Files:

  2. Palineto

    Palineto

    Joined:
    Dec 5, 2014
    Posts:
    4
    I've just realized that this was unnecessary and could've been ignored if there wasn't a SpriteRenderer on the prefab. lol