1 |
bd9a601b
|
Oto Šťáva
|
using UnityEngine;
|
2 |
|
|
|
3 |
|
|
namespace DeltaRobotVr.Components
|
4 |
|
|
{
|
5 |
|
|
/// <summary>
|
6 |
|
|
/// A generic implementation of vector visualization. The vector is determined by the <c>GetVector</c> method.
|
7 |
|
|
/// </summary>
|
8 |
|
|
public abstract class AbstractArrow : MonoBehaviour
|
9 |
|
|
{
|
10 |
|
|
protected LineRenderer _lineRenderer;
|
11 |
|
|
|
12 |
|
|
void Start()
|
13 |
|
|
{
|
14 |
|
|
_lineRenderer = GetComponent<LineRenderer>();
|
15 |
|
|
}
|
16 |
|
|
|
17 |
|
|
void Update()
|
18 |
|
|
{
|
19 |
|
|
if (Client.Instance.IsConnected)
|
20 |
|
|
{
|
21 |
|
|
var vector = GetVector();
|
22 |
|
|
_lineRenderer.SetPositions(new[] { Vector3.zero, Single3Utils.ToVector3(vector) * 2 });
|
23 |
|
|
}
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
/// <summary>
|
27 |
|
|
/// Gets the vector that this component renders.
|
28 |
|
|
/// </summary>
|
29 |
|
|
protected abstract Single3 GetVector();
|
30 |
|
|
}
|
31 |
|
|
}
|