Version: 5.3 (switch to 5.4b)
ЯзыкEnglish
  • C#
  • JS

Язык программирования

Выберите подходящий для вас язык программирования. Все примеры кода будут представлены на выбранном языке.

Mesh.colors

Руководство
public Color[] colors;

Описание

Vertex colors of the mesh.

If no vertex colors are available an empty array will be returned.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { Mesh mesh = GetComponent<MeshFilter>().mesh; Vector3[] vertices = mesh.vertices; Color[] colors = new Color[vertices.Length]; int i = 0; while (i < vertices.Length) { colors[i] = Color.Lerp(Color.red, Color.green, vertices[i].y); i++; } mesh.colors = colors; } }

For performance reasons, consider using colors32 instead. This will avoid byte-to-float conversions in colors, as well as use less temporary memory.