| | 1 | | using System; |
| | 2 | | using DCL; |
| | 3 | | using TMPro; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | | using Environment = DCL.Environment; |
| | 7 | |
|
| | 8 | | public class PreviewMenuPositionView : MonoBehaviour, IDisposable |
| | 9 | | { |
| | 10 | | [SerializeField] internal TMP_InputField xValueInputField; |
| | 11 | | [SerializeField] internal TMP_InputField yValueInputField; |
| | 12 | | [SerializeField] internal TMP_InputField zValueInputField; |
| | 13 | | [SerializeField] internal Button buttonReference; |
| | 14 | |
|
| | 15 | | private bool isDestroyed; |
| | 16 | |
|
| | 17 | | public void Dispose() |
| | 18 | | { |
| 5 | 19 | | if (!isDestroyed) |
| | 20 | | { |
| 5 | 21 | | Destroy(gameObject); |
| | 22 | | } |
| 5 | 23 | | } |
| | 24 | |
|
| | 25 | | private void OnDestroy() |
| | 26 | | { |
| 7 | 27 | | isDestroyed = true; |
| 7 | 28 | | } |
| | 29 | |
|
| | 30 | | private void Awake() |
| | 31 | | { |
| 7 | 32 | | buttonReference.onClick.AddListener(() => |
| | 33 | | { |
| 1 | 34 | | Environment.i.platform.clipboard |
| | 35 | | .WriteText($"{xValueInputField.text},{yValueInputField.text},{zValueInputField.text}"); |
| 1 | 36 | | }); |
| 7 | 37 | | } |
| | 38 | |
|
| | 39 | | internal static string FormatFloatValue(float value) |
| | 40 | | { |
| 12 | 41 | | return $"{value:0.00}"; |
| | 42 | | } |
| | 43 | |
|
| | 44 | | internal void LateUpdate() |
| | 45 | | { |
| 2 | 46 | | Vector3 position = WorldStateUtils.ConvertUnityToScenePosition(CommonScriptableObjects.playerUnityPosition.Get() |
| 2 | 47 | | xValueInputField.text = FormatFloatValue(position.x); |
| 2 | 48 | | yValueInputField.text = FormatFloatValue(position.y); |
| 2 | 49 | | zValueInputField.text = FormatFloatValue(position.z); |
| 2 | 50 | | } |
| | 51 | | } |