< Summary

Class:DCL.Controllers.ParcelSceneDebug.SceneDebugPlane
Assembly:DCL.Runtime
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneDebugPlane.cs
Covered lines:20
Uncovered lines:1
Coverable lines:21
Total lines:60
Line coverage:95.2% (20 of 21)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SceneDebugPlane(...)0%220100%
Dispose()0%3.023087.5%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneDebugPlane.cs

#LineLine coverage
 1using System;
 2using DCL.Configuration;
 3using DCL.Helpers;
 4using DCL.Models;
 5using UnityEngine;
 6
 7namespace DCL.Controllers.ParcelSceneDebug
 8{
 9    public class SceneDebugPlane : IDisposable
 10    {
 11        GameObject[] sceneParcelPlanes;
 12
 24913        public SceneDebugPlane(LoadParcelScenesMessage.UnityParcelScene sceneData, Transform parent)
 14        {
 24915            int sceneDataParcelsLength = sceneData.parcels.Length;
 24916            sceneParcelPlanes = new GameObject[sceneDataParcelsLength];
 17
 102018            for (int j = 0; j < sceneDataParcelsLength; j++)
 19            {
 26120                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
 26121                sceneParcelPlanes[j] = plane;
 22
 26123                UnityEngine.Object.Destroy(plane.GetComponent<MeshCollider>());
 24
 26125                plane.name = $"parcel:{sceneData.parcels[j].x},{sceneData.parcels[j].y}";
 26
 26127                plane.transform.SetParent(parent);
 28
 29                // the plane mesh with scale 1 occupies a 10 units space
 26130                plane.transform.localScale = new Vector3(ParcelSettings.PARCEL_SIZE * 0.1f, 1f,
 31                    ParcelSettings.PARCEL_SIZE * 0.1f);
 32
 26133                Vector3 position = Utils.GridToWorldPosition(sceneData.parcels[j].x, sceneData.parcels[j].y);
 34                // SET TO A POSITION RELATIVE TO basePosition
 35
 26136                position.Set(position.x + ParcelSettings.PARCEL_SIZE / 2, ParcelSettings.DEBUG_FLOOR_HEIGHT,
 37                    position.z + ParcelSettings.PARCEL_SIZE / 2);
 38
 26139                plane.transform.position = PositionUtils.WorldToUnityPosition(position);
 40
 26141                plane.GetComponent<MeshRenderer>().sharedMaterial = Utils.EnsureResourcesMaterial("Materials/DefaultPlan
 42            }
 24943        }
 44
 45        public void Dispose()
 46        {
 24947            if (sceneParcelPlanes == null)
 48            {
 049                return;
 50            }
 51
 102052            for (int i = 0; i < sceneParcelPlanes.Length; i++)
 53            {
 26154                UnityEngine.Object.Destroy(sceneParcelPlanes[i]);
 55            }
 56
 24957            sceneParcelPlanes = null;
 24958        }
 59    }
 60}