1 |
04839796
|
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 |
|
|
public float lengthMultiplier = 2;
|
11 |
|
|
|
12 |
|
|
void Update()
|
13 |
|
|
{
|
14 |
|
|
if (Client.Instance.IsConnected)
|
15 |
|
|
{
|
16 |
|
|
Vector3 v = Single3Utils.ToVector3(GetVector());
|
17 |
|
|
|
18 |
|
|
var t = transform;
|
19 |
|
|
t.rotation = Quaternion.FromToRotation(Vector3.forward, v);
|
20 |
|
|
t.localScale = new Vector3(1, 1, v.magnitude * lengthMultiplier);
|
21 |
|
|
}
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
/// <summary>
|
25 |
|
|
/// Gets the vector that this component renders.
|
26 |
|
|
/// </summary>
|
27 |
|
|
protected abstract Single3 GetVector();
|
28 |
|
|
}
|
29 |
|
|
}
|