Projekt

Obecné

Profil

Stáhnout (1.25 KB) Statistiky
| Větev: | Tag: | Revize:
1 04839796 Oto Šťáva
using UnityEngine;
2
3
namespace DeltaRobotVr.Components
4
{
5
    public class Curve : MonoBehaviour
6
    {
7
        private long _currentCounter;
8
        private LineRenderer _lineRenderer;
9 a5c3168d Oto Šťáva
10 04839796 Oto Šťáva
        void Start()
11
        {
12
            _currentCounter = Client.Instance.CurveCounter;
13
            _lineRenderer = GetComponent<LineRenderer>();
14 60d46688 Jakub Hejman
15
            // Set curve color
16 a5c3168d Oto Šťáva
            var color = Color.yellow;
17 60d46688 Jakub Hejman
            var cs = ConfigurationProvider.Instance.CurveColorHex;
18
            ColorUtility.TryParseHtmlString(cs, out color);
19 a5c3168d Oto Šťáva
            
20 60d46688 Jakub Hejman
            _lineRenderer.material.color = color;
21 a5c3168d Oto Šťáva
22
            var widthCurve = new AnimationCurve();
23
            widthCurve.AddKey(0.0f, ConfigurationProvider.Instance.VisualizationScaleOverall * 1);
24
            _lineRenderer.widthCurve = widthCurve;
25 04839796 Oto Šťáva
        }
26 60d46688 Jakub Hejman
27 04839796 Oto Šťáva
        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
}