02-Newtons-Laws icon indicating copy to clipboard operation
02-Newtons-Laws copied to clipboard

Deprecated public functions for LineRenderer

Open RobMeade opened this issue 7 years ago • 0 comments

As of Unity 5.5, the following public functions are deprecated for the LineRenderer;

SetColors SetWidth SetVertexCount

These are last documented in version 5.4 of the Unity Scripting API documentation; https://docs.unity3d.com/540/Documentation/ScriptReference/LineRenderer.html

These public functions are used within DrawForces.cs, which is provided within the NL02 Newtons Laws Assets.unitypackage, linked from Section 2, Lecture 7 (at time of writing). Additionally, these also appear within the PhysicsEngine.cs file, after the changes are made in Section 2, Lecture 13, and subsequently appear in the repository here.

At the time of writing, Unity 2018.2.2f1 still supports them but warns that they are deprecated.

The following lines of code can be used to replace the deprecated function calls and resolve this issue for more recent versions of Unity, 5.6 onwards;

lineRenderer.startColor = Color.yellow;
lineRenderer.endColor = Color.yellow;
lineRenderer.startWidth = 0.2f;
lineRenderer.endWidth = 0.2f;

and

lineRenderer.positionCount = numberOfForces * 2;

RobMeade avatar Aug 15 '18 20:08 RobMeade