47 lines
1.0 KiB
C#
Raw Normal View History

2020-07-28 15:59:24 +02:00
using UnityEngine;
namespace QSB.TransformSync
{
2020-07-28 15:59:24 +02:00
public class PlayerHUDMarker : HUDDistanceMarker
{
2020-08-08 12:25:09 +02:00
private PlayerInfo _player;
private bool _isReady;
protected override void InitCanvasMarker()
{
_markerRadius = 2f;
_markerTarget = new GameObject().transform;
_markerTarget.parent = transform;
_markerTarget.localPosition = Vector3.up * 2;
}
2020-08-08 12:25:09 +02:00
public void Init(PlayerInfo player)
{
2020-08-08 12:25:09 +02:00
_player = player;
_isReady = true;
}
protected override void RefreshOwnVisibility()
{
if (_canvasMarker != null)
{
_canvasMarker.SetVisibility(true);
}
}
2020-07-28 15:59:24 +02:00
private void Update()
{
2020-08-08 12:25:09 +02:00
if (!_isReady || !_player.IsReady)
{
2020-07-28 15:59:24 +02:00
return;
}
2020-08-08 12:25:09 +02:00
_markerLabel = _player.Name;
2020-07-28 15:59:24 +02:00
_isReady = false;
base.InitCanvasMarker();
}
}
}