Jakob
Jakob

Reputation: 72

Unity LineRenderer.GetPositions not working as intended

When trying to retrieve all positions from a line renderer by using the GetPositions method I am running into a problem. The documentation states, that the function can be used by passing a Vector3 array as an out parameter but it won't let me do that. Below is an excerpt of my code. It gives me the error "Argument 'pos' should not be passed with the 'out' keyword" at line 3

LineRenderer lineRenderer = this.GetComponent<LineRenderer>();
Vector3[] pos = new Vector3[lineRenderer.positionCount];
int test = lineRenderer.GetPositions(out pos);

Any ideas what I am doing wrong?

Upvotes: 0

Views: 686

Answers (2)

derHugo
derHugo

Reputation: 90590

The documentation of your link is for Unity version 2020. The out parameter was added in 2018.

You seem to be using an older version where the out was not there yet e.g. 2017 where there was no out parameter yet.

Always make sure to use the correct API version according to the Unity version you are using for your project ;)


Hm just looked into the source code and since even the LineRendererEditor uses it without out it seems to be a mistake in the documentation?!

Left a comment there so maybe it gets updated soon.

Upvotes: 1

Francesco - FL
Francesco - FL

Reputation: 715

If you remove the word "out" it will work

Upvotes: 0

Related Questions