LineRenderer GetPosition? not there.

hi i asked a question a few months ago here and someone said to use the getPosition and setPosition. but i looked in the lineRenderer class in the scripting reference and i could not find GetPosition.

is it possible that it was removed?


The reply you quoted said that it wasn't possible with the built in LineRenderer, and instead said to extend the original class

Sounds like a good plan to me - Something like this should do it (in c# - my js is too rusty for inheritance):

using System;
using UnityEngine;

public class AccessibleLineRenderer : LineRenderer
    private Vector3[] vertices = new Vector3[0]{};

    new public void SetPosition(int index, Vector3 position)
        vertices[index] = position;
        base.SetPosition(index, position);

    new public void SetVertexCount(int count)
        Array.Resize(ref vertices, count);

    public Vector3 GetPosition(int index)
        return vertices[index];

Hey, maybe I ll get the answer here…

private void axes()
	Debug.Log ("start line");
	Color c1 = Color.yellow;
	Color c2 =;
    	int lengthOfLineRenderer = 20;
        LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
        lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
        lineRenderer.SetColors(c1, c2);
        lineRenderer.SetWidth(0.01f, 0.9f);
	for(int i = 0; i < lengthOfLineRenderer; i++)
		Vector3 pos = new Vector3(i, 0.0f, 0f);
  			Vector3 pos2 = new                  Vector3(i,i,0.0f);

I tried different indexes, and hey? The line was rendered in different way - I just wanted have axis x and axis y, but I dot get, how the indexes working, and on unity website i found nothing… Do you know meaning of those indexes? Thx a lot!