Question by
Griefer_Denis_57 · Mar 21, 2017 at 07:49 PM ·
c#positionlinerendererlinenumber
error CS1061: Type `UnityEngine.LineRenderer' does not contain a definition for `numPositions' and no extension method `numPositions' of type `UnityEngine.LineRenderer' could be found
using System.Linq; using System.Collections.Generic; using UnityEngine;
public class Line : MonoBehaviour {
public LineRenderer lineRenderer;
public EdgeCollider2D edgeCol;
List<Vector2> points;
public void UpdateLine (Vector2 mousePos)
{
if (points == null)
{
points = new List<Vector2>();
SetPoint(mousePos);
return;
}
if (Vector2.Distance(points.Last(), mousePos) > .1f)
SetPoint(mousePos);
}
void SetPoint (Vector2 point)
{
points.Add(point);
lineRenderer.numPositions = points.Count;
lineRenderer.SetPosition(points.Count - 1, point);
if (points.Count > 1)
edgeCol.points = points.ToArray();
}
}
it just says numpositions doesnt exist, this is brackey's code but it doesnt work at all, i have the latest version of unity, is it only for the paid version?
Comment
Answer by LearnUnityNew · Mar 26, 2017 at 08:21 PM
Please install latest version ie unity 5.5.
I was also facing some problems, then updated scripts with some other alternatives but somehow figured that it might need latest version.