| | 1 | | using TMPro; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | internal class SpawnPointIndicatorMonoBehaviour : MonoBehaviour |
| | 5 | | { |
| | 6 | | [SerializeField] internal Transform lookAtIndicator; |
| | 7 | | [SerializeField] internal Transform areaIndicator; |
| | 8 | | [SerializeField] internal TextMeshPro areaText; |
| | 9 | |
|
| | 10 | | internal Transform areaTextTransform; |
| | 11 | |
|
| 0 | 12 | | public bool isDestroyed { private set; get; } |
| | 13 | |
|
| | 14 | | private void Awake() |
| | 15 | | { |
| 4 | 16 | | areaTextTransform = areaText.transform; |
| 4 | 17 | | } |
| | 18 | |
|
| | 19 | | private void OnDestroy() |
| | 20 | | { |
| 4 | 21 | | isDestroyed = true; |
| 4 | 22 | | } |
| | 23 | |
|
| | 24 | | private void LateUpdate() |
| | 25 | | { |
| 2 | 26 | | Vector3 lookAtDir = areaTextTransform.position - CommonScriptableObjects.cameraPosition; |
| 2 | 27 | | areaTextTransform.forward = lookAtDir.normalized; |
| 2 | 28 | | } |
| | 29 | |
|
| | 30 | | public void SetPosition(in Vector3 position) |
| | 31 | | { |
| 1 | 32 | | transform.position = position; |
| 1 | 33 | | areaIndicator.localPosition = Vector3.zero; |
| | 34 | |
|
| 1 | 35 | | lookAtIndicator.localPosition = new Vector3(0, lookAtIndicator.localPosition.y, 0); |
| 1 | 36 | | areaTextTransform.localPosition = new Vector3(0, areaTextTransform.localPosition.y, 0); |
| 1 | 37 | | } |
| | 38 | |
|
| | 39 | | public void SetRotation(in Quaternion? rotation) |
| | 40 | | { |
| 2 | 41 | | if (rotation.HasValue) |
| | 42 | | { |
| 1 | 43 | | lookAtIndicator.gameObject.SetActive(true); |
| 1 | 44 | | lookAtIndicator.rotation = rotation.Value; |
| 1 | 45 | | return; |
| | 46 | | } |
| 1 | 47 | | lookAtIndicator.gameObject.SetActive(false); |
| 1 | 48 | | } |
| | 49 | |
|
| | 50 | | public void SetSize(in Vector3 size) |
| | 51 | | { |
| 1 | 52 | | areaIndicator.localScale = size; |
| 1 | 53 | | var lookAtPosition = lookAtIndicator.localPosition; |
| 1 | 54 | | var textPosition = areaTextTransform.localPosition; |
| 1 | 55 | | lookAtPosition.y = textPosition.y = size.y * 0.5f; |
| | 56 | |
|
| 1 | 57 | | lookAtIndicator.localPosition = lookAtPosition; |
| 1 | 58 | | areaTextTransform.localPosition = textPosition; |
| 1 | 59 | | } |
| | 60 | |
|
| | 61 | | public void SetName(in string name) |
| | 62 | | { |
| 0 | 63 | | areaText.text = name; |
| 0 | 64 | | } |
| | 65 | | } |