< Summary

Class:DCL.Components.UIContainerRect
Assembly:DCL.Components.UI
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UI/UIContainer/UIContainerRect.cs
Covered lines:18
Uncovered lines:4
Coverable lines:22
Total lines:68
Line coverage:81.8% (18 of 22)
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
 6119            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 20        }
 21
 3322        public override string referencesContainerPrefabName => "UIContainerRect";
 23
 9924        public UIContainerRect() { model = new Model(); }
 25
 026        public override int GetClassId() { return (int) CLASS_ID.UI_CONTAINER_RECT; }
 27
 28        public override void AttachTo(IDCLEntity entity, System.Type overridenAttachedType = null)
 29        {
 030            Debug.LogError(
 31                "Aborted UIContainerRectShape attachment to an entity. UIShapes shouldn't be attached to entities.");
 032        }
 33
 034        public override void DetachFrom(IDCLEntity entity, System.Type overridenAttachedType = null) { }
 35
 36        public override IEnumerator ApplyChanges(BaseModel newModel)
 37        {
 6238            referencesContainer.image.color = new Color(model.color.r, model.color.g, model.color.b, model.color.a);
 6239            referencesContainer.image.raycastTarget = model.color.a >= RAYCAST_ALPHA_THRESHOLD;
 40
 6241            Outline outline = referencesContainer.image.GetComponent<Outline>();
 42
 6243            if (model.thickness > 0f)
 44            {
 345                if (outline == null)
 46                {
 347                    outline = referencesContainer.image.gameObject.AddComponent<Outline>();
 48                }
 49
 350                outline.effectDistance = new Vector2(model.thickness, model.thickness);
 51            }
 5952            else if (outline != null)
 53            {
 154                Object.DestroyImmediate(outline, false);
 55            }
 56
 6257            return null;
 58        }
 59
 60        public override void Dispose()
 61        {
 162            if (referencesContainer != null)
 163                Utils.SafeDestroy(referencesContainer.gameObject);
 64
 165            base.Dispose();
 166        }
 67    }
 68}