Hey all,
I’m trying to add points to a sprite shape in the form of a procedurally generated circle like this:
public void AddNode(GameObject node)
{
node.transform.SetParent(this.transform);
SpriteShape.spline.InsertPointAt(points.Count, node.transform.localPosition);
points.Add(node.transform);
SpriteShape.spline.SetTangentMode(points.Count - 1, ShapeTangentMode.Continuous);
SpringJoint2D sj = node.GetComponent<SpringJoint2D>();
sj.connectedBody = _rb;
}
,but the circle somehow keeps being inverted. Like this – the border is on the inside, and the fill is on the outside:
Yes, for those who recognize it, this is the open source CellCraft project that I’m porting from Flash to Unity. Getting the membrane right is the hardest task to date. The texture I’m using is just a 100x100 square with the border at the top.
When I enter the points manually and drag them around, it looks fine:
Any explanation/fix, from Sprite Shape experts? This really needs to be done procedurally, as the circle size needs to vary and change during gameplay.
EDIT: To forestall comments about open-endedness – I only turned that on in image 1 for the purpose of showing you the texture without the fill. When the shape is closed, it looks the same, with extra filling in the middle – the border is still on the inside.