2017-05-12 00:23:59 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Cyber.Util;
|
|
|
|
|
|
2017-05-12 01:03:27 +02:00
|
|
|
|
namespace Cyber.Util {
|
2017-05-12 00:23:59 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Helper component for hologram meshes.
|
|
|
|
|
/// </summary>
|
2017-05-12 01:03:27 +02:00
|
|
|
|
public class Hologram : MonoBehaviour {
|
2017-05-12 00:23:59 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether the hologram is visible or not.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Visible = true;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The texture that will handle the text which is displayed on this
|
|
|
|
|
/// hologram.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TextTextureApplier Text;
|
|
|
|
|
|
|
|
|
|
private float CurrentScale;
|
|
|
|
|
|
|
|
|
|
private void Start() {
|
2017-05-12 01:03:27 +02:00
|
|
|
|
CurrentScale = GetTargetScale();
|
2017-05-12 00:23:59 +02:00
|
|
|
|
UpdateScale();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update() {
|
2017-05-12 01:03:27 +02:00
|
|
|
|
if (GetTargetScale() != CurrentScale) {
|
2017-05-12 00:23:59 +02:00
|
|
|
|
UpdateScale();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateScale() {
|
2017-05-12 01:03:27 +02:00
|
|
|
|
float Scale = GetTargetScale();
|
2017-05-12 00:23:59 +02:00
|
|
|
|
CurrentScale = Mathf.Lerp(CurrentScale, Scale, 8f * Time.deltaTime);
|
2017-05-12 10:53:57 +02:00
|
|
|
|
if (Mathf.Abs(Scale - CurrentScale) < 0.001) {
|
2017-05-12 00:23:59 +02:00
|
|
|
|
CurrentScale = Scale;
|
|
|
|
|
}
|
|
|
|
|
transform.localScale =
|
|
|
|
|
new Vector3(CurrentScale, CurrentScale, CurrentScale);
|
|
|
|
|
}
|
2017-05-12 01:03:27 +02:00
|
|
|
|
|
|
|
|
|
private float GetTargetScale() {
|
|
|
|
|
return Visible ? 1 : 0;
|
|
|
|
|
}
|
2017-05-12 00:23:59 +02:00
|
|
|
|
}
|
|
|
|
|
}
|