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.

Scripting with ProBuilder - controlling UVs

Discussion in 'World Building' started by Koyemsi, Apr 27, 2018.

  1. Koyemsi

    Koyemsi

    Joined:
    Sep 25, 2017
    Posts:
    29
    Hi !
    I've recently learned how to script extrusions and create PB objects from scratch.
    Now I'd like to control the UVs, face by face, and I can't figure out how to do this through code. Getting a bit lost between SetUV(), pb_UV, pbUVOps...
    For example, I want one specific face to be :
    • tiled
    • anchored at middle center
    • have an Y offset
    • flip U
    • and so on...
    How would I translate this into script ?
    Thanx for any help.
     
  2. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    537
    You'd do this by setting the auto uv parameters on the face. Ex:

    Code (CSharp):
    1. var face = pb.faces[0];
    2. face.uv.flipU = true;
    3. face.uv.fill = Fill.Tile;
    4. // Rebuild the UVs
    5. pb.Refresh();
     
    Koyemsi and wolfen231 like this.
  3. Koyemsi

    Koyemsi

    Joined:
    Sep 25, 2017
    Posts:
    29
    That was exactly what I was looking for. Thanx a lot @kaarrrllll ll !
     
    Last edited: Apr 29, 2018