3d物体的仅Quad可用。
如果用其他3D物体,会报错
Mesh.uv is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
...
/// <summary>
/// Sets the frame.
/// </summary>
/// <param name="frame">Frame.</param>
public void SetFrame(int frame)
{
if (this._framesCount == 1)
{
return;
}
float xUnitSize = 1.0f / this._tilesX;
float yUnitSize = 1.0f / this._tilesY;
int xIndex = frame % this._tilesX;
int yIndex = frame / this._tilesX;
yIndex = this._tilesY - yIndex - 1;
Vector2[] uv = new Vector2[] {
//正常朝向右
/*new Vector2(xIndex * xUnitSize, yIndex * yUnitSize),//左下
new Vector2(xIndex * xUnitSize, yIndex * yUnitSize) + new Vector2(xUnitSize, 0),//右下
new Vector2(xIndex * xUnitSize, yIndex * yUnitSize) + new Vector2(0, yUnitSize),//左上
new Vector2(xIndex * xUnitSi

这篇博客介绍了如何在Unity中通过设置MeshRenderer的uv坐标来实现3D物体上的帧动画。特别指出,这种方法只适用于Quad,使用其他3D物体可能会导致‘uv out of bounds’错误。作者提供了完整的代码参考链接,帮助读者理解并应用这种技术。
最低0.47元/天 解锁文章
16万+

被折叠的 条评论
为什么被折叠?



