Search Unity

Resolved Modifying tiling and offset in shadergraph, is there a way to view this in edit mode?

Discussion in 'Shader Graph' started by axschacher, Nov 15, 2020.

  1. axschacher

    axschacher

    Joined:
    Mar 14, 2018
    Posts:
    21
    Edit: Solved my own problem, using [ExecuteAlways] on the script apply materialPropertyBlock.




    Modifying tiling and offset in shadergraph, is there a way to view this in edit mode?
    I'm guessing the answer is no, but I'm not sure how else to go about my problem.

    I have a single material with a large sprite sheet as the texture. I have a way to set the "frame" location on the sprite sheet, and apply that to a MaterialPropertyBlock. It works as intended in game, but the code I have that does this does not run until I hit play. When placing objects in the scene view, the frame isn't set correctly so is not representative of the object I am placing. Is there anything I can do to remedy this?

    Another path I started going down was creating a separate new quad for each object with ProBuilder, and manually setting the UV using ProBuilder. This allows the correct frame to be viewed in both edit and play mode, but I ran into a couple of issues down this route:

    First of all, I am not sure about the filesize footprint of creating a bunch of separate meshes for each quad, when they are the exact same geometry but just different UVs. Even if it isn't massive, it seems like a waste to create a ton of identical quad meshes, feels messy.

    Secondly, I could not figure out how to flip the UV coordinates in shadergraph. I got this working with my original graph, because I wasn't using UV coordinates, but offset and tiling. I can flip the texture, but trying to then move to UV back to the right spot.. could not figure this out.

    Thirdly, setting the UVs in ProBuilder is a mess, and the UV is never really set pixel-perfect. My frames in the texture are 1/128 the size, and the built in tool only expects you to be going down to 1/16.

    TLDR;
    Can you apply MaterialPropertyBlock values in Edit Mode? Alternatively, how can you move UV coordinates in shadergraph when flipping the scale of a texture to -1?

    Thanks for any help!
     
    Last edited: Nov 15, 2020