Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Scripting with ProBuilder - controlling UVs

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

  1. Koyemsi

    Koyemsi

    Joined:
    Sep 25, 2017
    Posts:
    10
    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:
    385
    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:
    10
    That was exactly what I was looking for. Thanx a lot @kaarrrllll ll !
     
    Last edited: Apr 29, 2018
unityunity