Ejemplo n.º 1
0
    void _Load()
    {
        _live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);


        _live2DModel.setTexture(0, textureFile);

        _layout = TextureAtlasLayout.loadJson(layoutFile.bytes);

        var frames = _layout.getFrames();
        int n      = frames.Count;

        for (int i = 0; i < n; i++)
        {
            var item = frames [i];
            _SetTextureMap(i, 0, _layout.width, _layout.height, item.srcWidth, item.srcHeight, item.x, item.y, item.trimX, item.trimY);
        }


        float modelWidth = _live2DModel.getCanvasWidth();

        _live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
    }
Ejemplo n.º 2
0
    //e.g)
    //{"frames": [
    //{
    //    "filename": "texture_00.png",
    //    "frame": {"x":2,"y":2,"w":1016,"h":1004},
    //    "spriteSourceSize": {"x":3,"y":13,"w":1016,"h":1004},
    //    "sourceSize": {"w":1024,"h":1024}
    //},
    //{
    //    "filename": "texture_01.png",
    //    "frame": {"x":1020,"y":2,"w":972,"h":1011},
    //    "spriteSourceSize": {"x":29,"y":4,"w":972,"h":1011},
    //    "sourceSize": {"w":1024,"h":1024}
    //}],
    //"meta": {
    //    "image": "texture_atlas.png",
    //    "size": {"w":2048,"h":2048}
    //}
    //}
    public static TextureAtlasLayout loadJson(Value json)
    {
        var ret = new TextureAtlasLayout();

        try
        {
            ret.image  = json.get("meta").get("image").toString();
            ret.width  = json.get("meta").get("size").get("w").toInt(0);
            ret.height = json.get("meta").get("size").get("h").toInt(0);

            var array = json.get("frames").getVector(null);
            int n     = array.Count;
            for (int i = 0; i < n; i++)
            {
                ret.frames.Add(TextureLayout.loadJson(array[i]));
            }
        }
        catch (Exception)
        {
            UtDebug.print("JSON Parse Error!");
        }

        return(ret);
    }