Наследование: MonoBehaviour
Пример #1
0
    void RenderMovin()
    {
        ClearChildren();

        mov = new Movin(transform, resourcePath, sortingLayer, scale, strokeWidth, loop, quality);
        mov.Play();
    }
Пример #2
0
 void ClearChildren()
 {
     for (int i = 0; i < transform.childCount; i++)
     {
         Object.DestroyImmediate(transform.GetChild(i).gameObject);
     }
     mov = null;
 }
Пример #3
0
        public MovinLayer(Movin movin, BodymovinLayer layer, int sort = 0)
        {
            this.movin   = movin;
            this.content = layer;
            this.sort    = sort;

            gameObject = new GameObject(content.ind + "  " + content.nm);
            transform.SetParent(movin.container.transform, false);

            positionOffset = content.positionOffset;

            transform.localPosition = content.position + positionOffset;
            transform.localRotation = content.rotation;
            transform.localScale    = content.scale;

            finalRotation = content.rotationEuler;


            /* ANIM SETUP */

            MotionSetup(ref positionAnimated, ref mpos, content.positionSets);
            MotionSetup(ref anchorAnimated, ref manchor, content.anchorSets);
            MotionSetup(ref scaleAnimated, ref mscale, content.scaleSets);
            MotionSetup(ref rotationXAnimated, ref mrotx, content.rotationXSets);
            MotionSetup(ref rotationYAnimated, ref mroty, content.rotationYSets);
            MotionSetup(ref rotationZAnimated, ref mrotz, content.rotationZSets);
            MotionSetup(ref opacityAnimated, ref mopacity, content.opacitySets);

            currentAnchor  = content.anchorPoint;
            currentOpacity = content.opacity;


            /* SHAPES */

            shapes = new MovinShape[content.shapes.Length];

            int j = 0;

            for (int i = content.shapes.Length - 1; i >= 0; i--)
            {
                MovinShape shape = new MovinShape(this, content.shapes[i]);
                shape.UpdateOpacity(content.opacity);
                shapes[i] = shape;

                //shape.transform.localPosition += new Vector3(0, 0, -32 * j);
                j += 1;
            }
        }
Пример #4
0
 void Start()
 {
     samurai = new Movin(transform, "json/samurai");
     samurai.Play();
 }
Пример #5
0
 void Start()
 {
     s = new Movin(transform, "json/circle", quality: 0.1f);
     s.Play();
 }
Пример #6
0
    void Start()
    {
        Movin m = new Movin(transform, "json/bust", quality: 0.2f);

        m.Play();
    }
Пример #7
0
 public void Start()
 {
     cub = new Movin(transform, "json/cub");
     Debug.Log(cub);
     cub.Play();
 }
Пример #8
0
        public MovinShape(MovinLayer layer, BodymovinShape content)
        {
            this.content = content;
            if (content.paths == null || content.paths.Length < 1)
            {
                Debug.Log("DON'T DRAW SHAPE -> NO PTS"); return;
            }

            this.layer = layer;
            this.movin = layer.movin;
            Transform parent = layer.transform;


            /* FIRST SHAPE PROPS */

            points    = (BodyPoint[])content.paths[0].points.Clone();
            motionSet = content.paths[0].animSets;
            closed    = content.paths[0].closed;



            /* ANIM SETUP */

            MotionSetup(ref animated, ref motion, motionSet);
            MotionSetup(ref strokeColorAnimated, ref mstrokec, content.strokeColorSets);
            MotionSetup(ref fillColorAnimated, ref mfillc, content.fillColorSets);



            /* GAMEOBJECT, MESH, MATERIAL */

            gameObject = new GameObject(content.item.ty + " pts: " + points.Length + "  closed: " + closed);
            transform.SetParent(parent, false);
            transform.localPosition = -layer.content.anchorPoint;

            mesh        = new Mesh();
            filter      = gameObject.AddComponent <MeshFilter>();
            filter.mesh = mesh;

            renderer          = gameObject.AddComponent <MeshRenderer>();
            renderer.material = new Material(Shader.Find("Sprites/Default"));
            //renderer.material = new Material(Shader.Find("Unlit/Vector"));

            sorting = gameObject.AddComponent <SortingGroup>();
            sorting.sortingOrder = movin.sort + layer.sort;


            /* SETUP VECTOR */

            Color stClr = (content.strokeColor == null) ? new Color(1, 1, 1) : new Color(content.strokeColor[0], content.strokeColor[1], content.strokeColor[2]);
            Color flClr = (content.fillColor == null) ? new Color(1, 1, 1) : new Color(content.fillColor[0], content.fillColor[1], content.fillColor[2]);

            currentStrokeColor = new Vector3(stClr.r, stClr.g, stClr.b);
            currentFillColor   = new Vector3(flClr.r, flClr.g, flClr.b);

            fill = content.fillHidden || content.fillColor == null ? null : new SolidFill()
            {
                Color = flClr
            };
            stroke = content.strokeHidden || content.strokeColor == null ? null : new Stroke()
            {
                Color = stClr, HalfThickness = content.strokeWidth * movin.strokeWidth
            };
            props = new PathProperties()
            {
                Stroke = stroke
            };

            shape = new Shape()
            {
                Fill          = fill,
                PathProps     = props,
                FillTransform = Matrix2D.identity
            };

            options = movin.options;

            scene = new Scene()
            {
                Root = new SceneNode()
                {
                    Shapes = new List <Shape> {
                        shape
                    }
                }
            };

            UpdateMesh();



            // ADDITIONAL SHAPE PATHS

            slaves = new MovinShapeSlave[content.paths.Length - 1];
            for (int i = 1; i <= slaves.Length; i++)
            {
                slaves[i - 1] = new MovinShapeSlave(this, content.paths[i], movin.strokeWidth);
            }
        }