public MovinLayer(Movin movin, BodymovinLayer layer, int sort = 0) { this.movin = movin; content = layer; this.sort = sort; transform.SetParent(movin.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; } }
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; 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 */ transform = new RectTransform(); transform.SetParent(parent, false); transform.localPosition = -layer.content.anchorPoint; /* 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 = Matrix3.I() }; 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); } }