azxkoop

各位好, 我是一名Unity程序员.
现在需要一个功能: 将Spine动画播放中的纹理截取出来, 存为Texture2D并作为Image 加载到场景中,然后做纹理变形,

我并没有在Spine API 中找到获取当前帧纹理信息的方法, 现在想的方案是新建一个Camera只照Spine对象获取RenderTexture, 但这样对于同时有多个不同Spine对象都需要处理的情况不是一个很好的方法, 特来请教

---

如果我能直接对Skeleton Mesh 操作 改变Mesh的顶点也可以达到效果 可是似乎SkeletonAnimation的Mesh信息无法被修改? 以下是我修改Mesh的代码:

MeshFilter _spineMF;
public void setVertexPosition (int idx, double x, double y) {
var mesh = _spineMF.mesh;

if (idx >= mesh.vertices.Length)
throw new System.Exception("setVertexPosition 顶点索引错误 = " + idx.ToString());

Vector3[] _vertices = mesh.vertices;
_vertices[idx] = new Vector3((float)x, -(float)y);

mesh.vertices = _vertices;
}
azxkoop
  • 帖子: 1

Harald

请参见示例场景“Spine Examples/Other Examples/Vertex Effect”,以获取有关如何在动画之后以及在将其分配给网格之前修改顶点的演示。

为此使用OnPostProcessVertices。
https://github.com/EsotericSoftware/spine-runtimes/blob/3.8/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs#L198
---
Please see the example scene Spine Examples/Other Examples/Vertex Effect for a demo of how to modify vertices after animation and before they are assigned at the Mesh.

OnPostProcessVertices is used for this purpose.
https://github.com/EsotericSoftware/spine-runtimes/blob/3.8/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs#L198
头像
Harald

Harri
  • 帖子: 2162


回到 中国Spine用户