我正在尝试为 Sprite 分配顶点颜色,每个实例都不同。
我已经设法编写了一个脚本来为 Sprite 网格设置顶点颜色:
private void SetVertexColors(Color32[] _vertexColors, Sprite _sprite) {
// set Colors NativeArray from Array
NativeArray<Color32> _vertexColorsNA = new NativeArray<Color32>(_vertexColors, Allocator.Temp);
// set Vertex Colors
_sprite.SetVertexAttribute(VertexAttribute.Color, _vertexColorsNA);
// dispose NativeArray
_vertexColorsNA.Dispose();
}
有没有办法让每个 Sprite 的顶点颜色都不同? 据我所知,Sprite Renderer 以某种方式在个人级别上使用 Color 设置顶点颜色。如何复制这种行为?