Пример #1
0
    public void Blend(string path, float duration = 30f, Vector2[] ease = null)
    {
        BodymovinContent blend = BodymovinContent.init(path);

        loop        = false;
        totalFrames = duration;

        time  = 0;
        frame = 0;

        blending     = true;
        blendPath    = path;
        blendContent = blend;

        if (ease == null)
        {
            ease = Ease.StrongOut;
        }

        for (int i = 0; i < layers.Length; i++)
        {
            layers[i].CreateBlendKeyframe(blend.layers[i], duration, ease);
        }

        Play();
    }
Пример #2
0
    public void UpdateLayersWithContent(BodymovinContent c, string path)
    {
        content = c;

        gameObject.name = "body - " + path;
        container.name  = "container - " + path;
        container.transform.localPosition  = Vector3.zero;
        container.transform.localPosition -= new Vector3(content.w / 2, -(content.h / 2), 0) * scale;

        frameRate   = content.fr;
        totalFrames = content.op;

        time  = 0;
        frame = 0;

        for (int i = 0; i < layers.Length; i++)
        {
            layers[i].UpdateLayersWithContent(content.layers[i]);
        }

        loop = true;
        Play();
    }
Пример #3
0
    private void MovinInit(string path, int sort = 0, float scale = 1f, float strokeWidth = 0.5f, bool loop = true, float quality = 0.4f)
    {
        scale *= 0.1f;  // Reduce default scale

        gameObject.name = "body - " + path;
        container.name  = "container - " + path;

        this.loop        = loop;
        this.sort        = sort;
        this.scale       = scale;
        this.strokeWidth = strokeWidth;

        content = BodymovinContent.init(path);

        if (content.layers == null || content.layers.Length <= 0)
        {
            Debug.Log(">>>>  NO CONTENT LAYERS, ABORT!  <<<<");
            return;
        }

        container.transform.localScale     = Vector3.one * this.scale;
        container.transform.localPosition -= new Vector3(content.w / 2, -(content.h / 2), 0) * scale;

        frameRate   = content.fr;
        totalFrames = content.op;
        layers      = new MovinLayer[content.layers.Length];


        /* ----- SHAPE OPTIONS ----- */

        options = new VectorUtils.TessellationOptions()
        {
            StepDistance         = 1000.0f,
            MaxCordDeviation     = 0.05f,
            MaxTanAngleDeviation = 0.05f,
            // SamplingStepSize = 0.01f
            SamplingStepSize = quality
        };


        /* ----- CREATE LAYERS ----- */

        layersByIndex = new MovinLayer[content.highestLayerIndex + 1];

        for (int i = 0; i < content.layers.Length; i++)
        {
            MovinLayer layer = new MovinLayer(this, content.layers[i], content.layers.Length - i);

            layers[i] = layer;
            layersByIndex[layer.content.ind] = layers[i];
        }



        /* ----- SET PARENTS ----- */

        for (int i = 0; i < layers.Length; i++)
        {
            MovinLayer layer = layers[i];
            int        p     = layer.content.parent;
            if (p <= 0)
            {
                continue;
            }

            layer.transform.SetParent(layersByIndex[p].content.shapes.Length > 0 ?
                                      layersByIndex[p].transform.GetChild(0) : layersByIndex[p].transform, false);
        }
    }
Пример #4
0
    /*  REPLACE EXISTING LAYER CONTENT WITH NEW DATA  */


    public void UpdateLayersWithContent(string path)
    {
        UpdateLayersWithContent(BodymovinContent.init(path), path);
    }