public static void SetColor(VectorLine line, Color color) { if (line.lineColors == null) { line.SetupVertexColors(); } int end = line.lineColors.Length; for (int i = 0; i < end; i++) { line.lineColors[i] = color; } line.mesh.colors = line.lineColors; }
public static void SetColors(VectorLine line, Color[] lineColors) { if (line.lineColors == null) { line.SetupVertexColors(); } if (!line.isPoints) { if (WrongArrayLength (line, lineColors.Length, FunctionName.SetColors)) { return; } } else if (lineColors.Length != GetPointsLength(line)) { LogError("Vector: SetColors: Length of lineColors array in " + line.vectorObject.name + " must be same length as points array"); return; } int start = 0; int end = lineColors.Length; SetStartAndEnd (line, ref start, ref end); int idx = start*4; for (int i = start; i < end; i++) { line.lineColors[idx] = lineColors[i]; line.lineColors[idx+1] = lineColors[i]; line.lineColors[idx+2] = lineColors[i]; line.lineColors[idx+3] = lineColors[i]; idx += 4; } line.mesh.colors = line.lineColors; }
public static void SetColorsSmooth(VectorLine line, Color[] lineColors) { if (line.isPoints) { LogError ("Vector: SetColorsSmooth must be used with a line rather than points"); return; } if (line.lineColors == null) { line.SetupVertexColors(); } if (WrongArrayLength (line, lineColors.Length, FunctionName.SetColorsSmooth)) { return; } int start = 0; int end = lineColors.Length; SetStartAndEnd (line, ref start, ref end); int idx = start*4; line.lineColors[idx ] = lineColors[start]; line.lineColors[idx+1] = lineColors[start]; line.lineColors[idx+2] = lineColors[start]; line.lineColors[idx+3] = lineColors[start]; idx += 4; for (int i = start+1; i < end; i++) { line.lineColors[idx ] = lineColors[i-1]; line.lineColors[idx+1] = lineColors[i-1]; line.lineColors[idx+2] = lineColors[i]; line.lineColors[idx+3] = lineColors[i]; idx += 4; } line.mesh.colors = line.lineColors; }