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; } }
public MovinShapeSlave(MovinShape master, BodymovinShapePath path, float strokeWidth = 1f) { this.master = master; this.path = path; Transform parent = master.transform.parent; /* SHAPE PROPS */ points = (BodyPoint[])path.points.Clone(); motionSet = path.animSets; closed = path.closed; /* ANIM SETUP */ MotionSetup(ref animated, ref motion, motionSet); /* GAMEOBJECT */ gameObject = new GameObject(master.content.item.ty + " pts: " + points.Length + " closed: " + closed); transform.SetParent(parent, false); transform.localPosition = master.transform.localPosition; mesh = new Mesh(); filter = gameObject.AddComponent <MeshFilter>(); filter.mesh = mesh; renderer = gameObject.AddComponent <MeshRenderer>(); renderer.material = master.renderer.material; sorting = gameObject.AddComponent <UnityEngine.Rendering.SortingGroup>(); sorting.sortingOrder = master.sorting.sortingOrder; /* SETUP VECTOR */ fill = master.content.fillHidden || master.content.fillColor == null ? null : new SolidFill() { Color = master.fill.Color }; stroke = master.content.strokeHidden || master.content.strokeColor == null ? null : new Stroke() { Color = master.stroke.Color, HalfThickness = master.content.strokeWidth * strokeWidth }; props = new PathProperties() { Stroke = stroke }; shape = new Shape() { Fill = fill, PathProps = props, FillTransform = Matrix2D.identity }; options = master.options; scene = new Scene() { Root = new SceneNode() { Shapes = new List <Shape> { shape } } }; UpdateMesh(); }