< Summary

Class:EntityWireframe
Assembly:DebugPlugins_ShapesBoundingBoxDisplayer
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/DebugPlugins/ShapesBoundingBoxDisplayer/EntityWireframe.cs
Covered lines:17
Uncovered lines:3
Coverable lines:20
Total lines:52
Line coverage:85% (17 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
EntityWireframe(...)0%2100%
Dispose()0%110100%
OnShapeUpdated(...)0%220100%
OnShapeCleaned(...)0%110100%
CleanWireframe()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/DebugPlugins/ShapesBoundingBoxDisplayer/EntityWireframe.cs

#LineLine coverage
 1using System;
 2using DCL.Models;
 3using DCLPlugins.DebugPlugins.Commons;
 4using UnityEngine;
 5using Object = UnityEngine.Object;
 6
 7internal class EntityWireframe : IShapeListener
 8{
 9    private const float WIREFRAME_SIZE_MULTIPLIER = 1.01f;
 10
 11    private readonly GameObject wireframeOriginal;
 12
 13    private GameObject entityWireframe;
 14
 015    public EntityWireframe(GameObject wireframeOriginal)
 16    {
 017        this.wireframeOriginal = wireframeOriginal;
 018    }
 19
 20    void IDisposable.Dispose()
 21    {
 1622        CleanWireframe();
 1623    }
 24
 25    void IShapeListener.OnShapeUpdated(IDCLEntity entity)
 26    {
 1627        entityWireframe ??= Object.Instantiate(wireframeOriginal);
 28
 1629        Transform wireframeT = entityWireframe.transform;
 30
 1631        wireframeT.position = entity.meshesInfo.mergedBounds.center;
 1632        wireframeT.localScale = entity.meshesInfo.mergedBounds.size * WIREFRAME_SIZE_MULTIPLIER;
 33
 1634        wireframeT.SetParent(entity.gameObject.transform);
 1635        entityWireframe.SetActive(true);
 1636    }
 37
 38    void IShapeListener.OnShapeCleaned(IDCLEntity entity)
 39    {
 140        CleanWireframe();
 141    }
 42
 43    private void CleanWireframe()
 44    {
 1745        if (entityWireframe == null)
 146            return;
 47
 1648        entityWireframe.SetActive(false);
 1649        Object.Destroy(entityWireframe);
 1650        entityWireframe = null;
 1651    }
 52}