1
|
using UnityEngine;
|
2
|
|
3
|
namespace DeltaRobotVr.Components
|
4
|
{
|
5
|
public class Curve : MonoBehaviour
|
6
|
{
|
7
|
private long _currentCounter;
|
8
|
private LineRenderer _lineRenderer;
|
9
|
|
10
|
void Start()
|
11
|
{
|
12
|
_currentCounter = Client.Instance.CurveCounter;
|
13
|
_lineRenderer = GetComponent<LineRenderer>();
|
14
|
|
15
|
// Set curve color
|
16
|
var color = Color.yellow;
|
17
|
var cs = ConfigurationProvider.Instance.CurveColorHex;
|
18
|
ColorUtility.TryParseHtmlString(cs, out color);
|
19
|
|
20
|
_lineRenderer.material.color = color;
|
21
|
|
22
|
var widthCurve = new AnimationCurve();
|
23
|
widthCurve.AddKey(0.0f, ConfigurationProvider.Instance.VisualizationScaleOverall * 1);
|
24
|
_lineRenderer.widthCurve = widthCurve;
|
25
|
}
|
26
|
|
27
|
void Update()
|
28
|
{
|
29
|
if (Client.Instance.IsConnected)
|
30
|
{
|
31
|
var counter = Client.Instance.CurveCounter;
|
32
|
if(counter != _currentCounter && Client.Instance.Curve != null)
|
33
|
{
|
34
|
_lineRenderer.positionCount = Client.Instance.Curve.Length;
|
35
|
_lineRenderer.SetPositions(Single3Utils.ToVector3(Client.Instance.Curve));
|
36
|
}
|
37
|
}
|
38
|
}
|
39
|
}
|
40
|
}
|