SHARE
TWEET

Untitled

a guest Feb 15th, 2019 8 in 152 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public static void LoadAtlasUvs() {
  2.         int textureSize = 8; // 8x8
  3.         int columnCount = atlasTexture.width / textureSize;
  4.         int rowCount = atlasTexture.height / textureSize;
  5.         for (int x = 0; x < rowCount - 1; x++) {
  6.             for (int z = 0; z < columnCount - 1; z++) {
  7.                 float
  8.                     uv1x = 1f/rowCount,
  9.                     uv2x = 0,
  10.                     uv3x = 0,
  11.                     uv4x = 1f/rowCount;
  12.                 float
  13.                     uv1z = (1f/columnCount),
  14.                     uv2z = (1f/columnCount),
  15.                     uv3z = 0,
  16.                     uv4z = 0;
  17.                 if (x != 0) {
  18.                     uv1x = (x + 1.0f) / rowCount;
  19.                     uv2x = (float)x / rowCount;
  20.                     uv3x = (float)x / rowCount;
  21.                     uv4x = (x + 1.0f) / rowCount;
  22.                 }
  23.                 if (z != 0) {
  24.                     uv1z = (z + 1.0f) / columnCount;
  25.                     uv2z = (z + 1.0f) / columnCount;
  26.                     uv3z = (float)z / columnCount;
  27.                     uv4z = (float)z / columnCount;
  28.                 }
  29.                 Vector2[] uvs = {
  30.                     new Vector2(uv1x, uv1z),
  31.                     new Vector2(uv2x, uv2z),
  32.                     new Vector2(uv3x, uv3z),
  33.                     new Vector2(uv4x, uv4z),
  34.                 };
  35.                 atlasUvs.Add(x+","+z, uvs);
  36.             }
  37.         }
  38.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top