Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i add spine's skeletongraphic like this #208

Open
woshihuo12 opened this issue Apr 3, 2020 · 0 comments
Open

i add spine's skeletongraphic like this #208

woshihuo12 opened this issue Apr 3, 2020 · 0 comments
Assignees

Comments

@woshihuo12
Copy link

private void Awake()
{
mSkeletonGraphic = GetComponent();
mSkeletonGraphic.OnPostProcessVertices += OnPostProcessSkeletonGraphic;
}

    private void OnPostProcessSkeletonGraphic(MeshGeneratorBuffers buffers)
    {
        if (!isActiveAndEnabled)
            return;

        float normalizedIndex = ptex.GetNormalizedIndex(this);

        // rect.
        Rect rect = m_EffectArea.GetSpineEffectArea(buffers, rectTransform.rect);

        // rotation.
        float rad = m_Rotation * Mathf.Deg2Rad;
        Vector2 dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad));
        dir.x *= rect.height / rect.width;
        dir = dir.normalized;

        // Calculate vertex position.
        Vector2 nomalizedPos;
        Matrix2x3 localMatrix = new Matrix2x3(rect, dir.x, dir.y);  // Get local matrix.
        for (int i = 0; i < buffers.vertexCount; i++)
        {
            var vertex = buffers.vertexBuffer[i];
            m_EffectArea.GetNormalizedFactor(i, localMatrix, vertex, true, out nomalizedPos);

            var curUv = buffers.uvBuffer[i];

            buffers.uvBuffer[i] = new Vector2(
                Packer.ToFloat(curUv.x, curUv.y),
                Packer.ToFloat(nomalizedPos.y, normalizedIndex)
            );
        }
    }

so , no need modify mesh method.

@mob-sakai mob-sakai self-assigned this May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants