diff --git a/spine-csharp/src/IkConstraint.cs b/spine-csharp/src/IkConstraint.cs index c71fb0fa4..bc92980da 100644 --- a/spine-csharp/src/IkConstraint.cs +++ b/spine-csharp/src/IkConstraint.cs @@ -52,26 +52,24 @@ namespace Spine { public IkConstraint (IkConstraintData data, Skeleton skeleton) { if (data == null) throw new ArgumentNullException("data", "data cannot be null."); this.data = data; - mix = data.mix; - softness = data.softness; - bendDirection = data.bendDirection; - compress = data.compress; - stretch = data.stretch; bones = new ExposedList(data.bones.Count); foreach (BoneData boneData in data.bones) bones.Add(skeleton.bones.Items[boneData.index]); target = skeleton.bones.Items[data.target.index]; + + mix = data.mix; + softness = data.softness; + bendDirection = data.bendDirection; + compress = data.compress; + stretch = data.stretch; } /// Copy constructor. - public IkConstraint (IkConstraint constraint) { - if (constraint == null) throw new ArgumentNullException("constraint", "constraint cannot be null."); - data = constraint.data; - bones = new ExposedList(constraint.Bones.Count); - bones.AddRange(constraint.Bones); - target = constraint.target; + public IkConstraint (IkConstraint constraint, Skeleton skeleton) + : this(constraint.data, skeleton) { + mix = constraint.mix; softness = constraint.softness; bendDirection = constraint.bendDirection; diff --git a/spine-csharp/src/PathConstraint.cs b/spine-csharp/src/PathConstraint.cs index 6a8c9b775..0a13c45c2 100644 --- a/spine-csharp/src/PathConstraint.cs +++ b/spine-csharp/src/PathConstraint.cs @@ -64,6 +64,7 @@ namespace Spine { bones.Add(skeleton.bones.Items[boneData.index]); target = skeleton.slots.Items[data.target.index]; + position = data.position; spacing = data.spacing; mixRotate = data.mixRotate; @@ -72,12 +73,9 @@ namespace Spine { } /// Copy constructor. - public PathConstraint (PathConstraint constraint) { - if (constraint == null) throw new ArgumentNullException("constraint cannot be null."); - data = constraint.data; - bones = new ExposedList(constraint.Bones.Count); - bones.AddRange(constraint.Bones); - target = constraint.target; + public PathConstraint (PathConstraint constraint, Skeleton skeleton) + : this(constraint.data, skeleton) { + position = constraint.position; spacing = constraint.spacing; mixRotate = constraint.mixRotate; diff --git a/spine-csharp/src/PhysicsConstraint.cs b/spine-csharp/src/PhysicsConstraint.cs index aede953ec..4221b0aec 100644 --- a/spine-csharp/src/PhysicsConstraint.cs +++ b/spine-csharp/src/PhysicsConstraint.cs @@ -60,7 +60,9 @@ namespace Spine { if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null."); this.data = data; this.skeleton = skeleton; + bone = skeleton.bones.Items[data.bone.index]; + inertia = data.inertia; strength = data.strength; damping = data.damping; @@ -71,11 +73,9 @@ namespace Spine { } /// Copy constructor. - public PhysicsConstraint (PhysicsConstraint constraint) { - if (constraint == null) throw new ArgumentNullException("constraint", "constraint cannot be null."); - data = constraint.data; - skeleton = constraint.skeleton; - bone = constraint.bone; + public PhysicsConstraint (PhysicsConstraint constraint, Skeleton skeleton) + : this(constraint.data, skeleton) { + inertia = constraint.inertia; strength = constraint.strength; damping = constraint.damping; diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index 774e2472b..522b27fc6 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -187,19 +187,19 @@ namespace Spine { ikConstraints = new ExposedList(skeleton.ikConstraints.Count); foreach (IkConstraint ikConstraint in skeleton.ikConstraints) - ikConstraints.Add(new IkConstraint(ikConstraint)); + ikConstraints.Add(new IkConstraint(ikConstraint, skeleton)); transformConstraints = new ExposedList(skeleton.transformConstraints.Count); foreach (TransformConstraint transformConstraint in skeleton.transformConstraints) - transformConstraints.Add(new TransformConstraint(transformConstraint)); + transformConstraints.Add(new TransformConstraint(transformConstraint, skeleton)); pathConstraints = new ExposedList(skeleton.pathConstraints.Count); foreach (PathConstraint pathConstraint in skeleton.pathConstraints) - pathConstraints.Add(new PathConstraint(pathConstraint)); + pathConstraints.Add(new PathConstraint(pathConstraint, skeleton)); physicsConstraints = new ExposedList(skeleton.physicsConstraints.Count); foreach (PhysicsConstraint physicsConstraint in skeleton.physicsConstraints) - physicsConstraints.Add(new PhysicsConstraint(physicsConstraint)); + physicsConstraints.Add(new PhysicsConstraint(physicsConstraint, skeleton)); skin = skeleton.skin; r = skeleton.r; diff --git a/spine-csharp/src/TransformConstraint.cs b/spine-csharp/src/TransformConstraint.cs index e234de305..2d50fc210 100644 --- a/spine-csharp/src/TransformConstraint.cs +++ b/spine-csharp/src/TransformConstraint.cs @@ -51,27 +51,25 @@ namespace Spine { if (data == null) throw new ArgumentNullException("data", "data cannot be null."); if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null."); this.data = data; - mixRotate = data.mixRotate; - mixX = data.mixX; - mixY = data.mixY; - mixScaleX = data.mixScaleX; - mixScaleY = data.mixScaleY; - mixShearY = data.mixShearY; bones = new ExposedList(); foreach (BoneData boneData in data.bones) bones.Add(skeleton.bones.Items[boneData.index]); target = skeleton.bones.Items[data.target.index]; + + mixRotate = data.mixRotate; + mixX = data.mixX; + mixY = data.mixY; + mixScaleX = data.mixScaleX; + mixScaleY = data.mixScaleY; + mixShearY = data.mixShearY; } /// Copy constructor. - public TransformConstraint (TransformConstraint constraint) { - if (constraint == null) throw new ArgumentNullException("constraint cannot be null."); - data = constraint.data; - bones = new ExposedList(constraint.Bones.Count); - bones.AddRange(constraint.Bones); - target = constraint.target; + public TransformConstraint (TransformConstraint constraint, Skeleton skeleton) + : this(constraint.data, skeleton) { + mixRotate = constraint.mixRotate; mixX = constraint.mixX; mixY = constraint.mixY; diff --git a/spine-csharp/src/package.json b/spine-csharp/src/package.json index c24efb7bb..e581b197d 100644 --- a/spine-csharp/src/package.json +++ b/spine-csharp/src/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-csharp", "displayName": "spine-csharp Runtime", "description": "This plugin provides the spine-csharp core runtime.", - "version": "4.2.20", + "version": "4.2.21", "unity": "2018.3", "author": { "name": "Esoteric Software",