Beispiel #1
0
 void SetSide(CubeUVs cubeUVs, char sideName, JSONFrame frame)
 {
     switch (sideName)
     {
         case 't':
             cubeUVs.top = GetUV(frame.x, 1 - frame.y - frame.h, frame.w, frame.h);
             break;
         case 's':
             cubeUVs.side = GetUV(frame.x, 1 - frame.y - frame.h, frame.w, frame.h);
             break;
         case 'b':
             cubeUVs.bottom = GetUV(frame.x, 1 - frame.y - frame.h, frame.w, frame.h);
             break;
     }
 }
Beispiel #2
0
        void UpdateDic()
        {
            //      Log.Add(text.text);

            JSONTexture texture = JsonUtility.FromJson<JSONTexture>(text.text);

            var cubesUVs = new CubeUVs[texture.frames.Length];

            var frames = texture.frames;

            //foreach (JSONFrame frame in frames.frames)
            for (int i = 0; i < frames.Length; i++)
            {
                var frame = frames [i];

                var name = frame.name;

                var underscoreIndex = name.LastIndexOf("_");

                if (underscoreIndex <= 0)
                {
                    //     throw new Exception("Wrong texture file name in texture atlas. You must use somefilename_t, somefilename_s, somefilename_b. You use: " + filename);
                    continue;
                }

                var textureIndex = GetTextureIndex(name, underscoreIndex);
                var sideName = GetSideName(name, underscoreIndex);

                CubeUVs cubeUVs = cubesUVs [textureIndex];

                if (cubeUVs != null)
                {
                    SetSide(cubeUVs, sideName, frame);//, texture.meta.size);
                } else
                {
                    cubeUVs = new CubeUVs();
                    SetSide(cubeUVs, sideName, frame);//.frame, texture.meta.size);
                    cubesUVs [textureIndex] = cubeUVs;
                }
            }
            CubesUVs.cubesUVs = cubesUVs;
        }