< Summary

Class:PreviewMenuPositionView
Assembly:DebugPlugins_PreviewMenu
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/DebugPlugins/PreviewMenu/View/Scripts/PreviewMenuPositionView.cs
Covered lines:19
Uncovered lines:3
Coverable lines:22
Total lines:73
Line coverage:86.3% (19 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PreviewMenuPositionView()0%110100%
Dispose()0%220100%
OnDestroy()0%110100%
Awake()0%110100%
FormatFloatValue(...)0%110100%
LateUpdate()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/DebugPlugins/PreviewMenu/View/Scripts/PreviewMenuPositionView.cs

#LineLine coverage
 1using System;
 2using DCL;
 3using DCL.NotificationModel;
 4using TMPro;
 5using UnityEngine;
 6using UnityEngine.UI;
 7using Environment = DCL.Environment;
 8using Type = DCL.NotificationModel.Type;
 9
 10public class PreviewMenuPositionView : MonoBehaviour, IDisposable
 11{
 12    private const string NOTIFICATION_GROUP = "PositionCopiedToClipboard";
 13    private const string NOTIFICATION_MESSAGE = "Position copied to clipboard ({0})";
 14
 15    [SerializeField] internal TMP_InputField xValueInputField;
 16    [SerializeField] internal TMP_InputField yValueInputField;
 17    [SerializeField] internal TMP_InputField zValueInputField;
 18    [SerializeField] internal Button buttonReference;
 19
 20    private bool isDestroyed;
 21
 122    private static readonly Model copyPositionToast = new Model()
 23    {
 24        type = Type.WARNING,
 25        groupID = NOTIFICATION_GROUP,
 26        message = NOTIFICATION_MESSAGE,
 27        timer = 1.5f
 28    };
 29
 30    public void Dispose()
 31    {
 532        if (!isDestroyed)
 33        {
 534            Destroy(gameObject);
 35        }
 536    }
 37
 38    private void OnDestroy()
 39    {
 740        isDestroyed = true;
 741    }
 42
 43    private void Awake()
 44    {
 745        buttonReference.onClick.AddListener(() =>
 46        {
 147            var positionString = $"{xValueInputField.text},{yValueInputField.text},{zValueInputField.text}";
 148            Environment.i.platform.clipboard
 49                       .WriteText(positionString);
 50
 151            var notificationController = NotificationsController.i;
 152            if (notificationController != null)
 53            {
 054                copyPositionToast.message = string.Format(NOTIFICATION_MESSAGE, positionString);
 055                notificationController.DismissAllNotifications(copyPositionToast.groupID);
 056                notificationController.ShowNotification(copyPositionToast);
 57            }
 158        });
 759    }
 60
 61    internal static string FormatFloatValue(float value)
 62    {
 1263        return $"{value:0.00}";
 64    }
 65
 66    internal void LateUpdate()
 67    {
 268        Vector3 position = WorldStateUtils.ConvertUnityToScenePosition(CommonScriptableObjects.playerUnityPosition.Get()
 269        xValueInputField.text = FormatFloatValue(position.x);
 270        yValueInputField.text = FormatFloatValue(position.y);
 271        zValueInputField.text = FormatFloatValue(position.z);
 272    }
 73}