< Summary

Class:DCL.Components.UIContainerRect
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UI/UIContainer/UIContainerRect.cs
Covered lines:19
Uncovered lines:4
Coverable lines:23
Total lines:70
Line coverage:82.6% (19 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Model()0%110100%
GetDataFromJSON(...)0%110100%
UIContainerRect()0%110100%
GetClassId()0%2100%
AttachTo(...)0%2100%
DetachFrom(...)0%2100%
ApplyChanges(...)0%440100%
Dispose()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UI/UIContainer/UIContainerRect.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using DCL.Models;
 4using System.Collections;
 5using System.Collections.Generic;
 6using UnityEngine;
 7using UnityEngine.UI;
 8
 9namespace DCL.Components
 10{
 11    public class UIContainerRect : UIShape<UIContainerRectReferencesContainer, UIContainerRect.Model>
 12    {
 13        [System.Serializable]
 14        new public class Model : UIShape.Model
 15        {
 16            public float thickness = 0f;
 15717            public Color color = Color.clear;
 18            public bool adaptWidth = false;
 19            public bool adaptHeight = false;
 20
 6121            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 22        }
 23
 3324        public override string referencesContainerPrefabName => "UIContainerRect";
 25
 9926        public UIContainerRect() { model = new Model(); }
 27
 028        public override int GetClassId() { return (int) CLASS_ID.UI_CONTAINER_RECT; }
 29
 30        public override void AttachTo(IDCLEntity entity, System.Type overridenAttachedType = null)
 31        {
 032            Debug.LogError(
 33                "Aborted UIContainerRectShape attachment to an entity. UIShapes shouldn't be attached to entities.");
 034        }
 35
 036        public override void DetachFrom(IDCLEntity entity, System.Type overridenAttachedType = null) { }
 37
 38        public override IEnumerator ApplyChanges(BaseModel newModel)
 39        {
 6240            referencesContainer.image.color = new Color(model.color.r, model.color.g, model.color.b, model.color.a);
 6241            referencesContainer.image.raycastTarget = model.color.a >= RAYCAST_ALPHA_THRESHOLD;
 42
 6243            Outline outline = referencesContainer.image.GetComponent<Outline>();
 44
 6245            if (model.thickness > 0f)
 46            {
 347                if (outline == null)
 48                {
 349                    outline = referencesContainer.image.gameObject.AddComponent<Outline>();
 50                }
 51
 352                outline.effectDistance = new Vector2(model.thickness, model.thickness);
 353            }
 5954            else if (outline != null)
 55            {
 156                Object.DestroyImmediate(outline, false);
 57            }
 58
 6259            return null;
 60        }
 61
 62        public override void Dispose()
 63        {
 3464            if (referencesContainer != null)
 2565                Utils.SafeDestroy(referencesContainer.gameObject);
 66
 3467            base.Dispose();
 3468        }
 69    }
 70}