< Summary

Class:UIComponentsPlugin
Assembly:DCL.Plugins.UIComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UIComponentsPlugin/UIComponentsPlugin.cs
Covered lines:29
Uncovered lines:1
Coverable lines:30
Total lines:63
Line coverage:96.6% (29 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UIComponentsPlugin()0%110100%
CanCreateScreenShape(...)0%2.062075%
BuildComponent[T]()0%110100%
Dispose()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UIComponentsPlugin/UIComponentsPlugin.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using DCL;
 4using DCL.Components;
 5using DCL.Controllers;
 6using DCL.Models;
 7using UnityEngine;
 8
 9public class UIComponentsPlugin : IPlugin
 10{
 6111    public UIComponentsPlugin()
 12    {
 6113        IRuntimeComponentFactory factory = Environment.i.world.componentFactory;
 14
 15        // UI
 6116        factory.RegisterBuilder((int) CLASS_ID.UI_INPUT_TEXT_SHAPE, BuildComponent<UIInputText>);
 6117        factory.RegisterBuilder((int) CLASS_ID.UI_FULLSCREEN_SHAPE, BuildComponent<UIScreenSpace>);
 6118        factory.RegisterBuilder((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE, BuildComponent<UIScreenSpace>);
 6119        factory.RegisterBuilder((int) CLASS_ID.UI_CONTAINER_RECT, BuildComponent<UIContainerRect>);
 6120        factory.RegisterBuilder((int) CLASS_ID.UI_SLIDER_SHAPE, BuildComponent<UIScrollRect>);
 6121        factory.RegisterBuilder((int) CLASS_ID.UI_CONTAINER_STACK, BuildComponent<UIContainerStack>);
 6122        factory.RegisterBuilder((int) CLASS_ID.UI_IMAGE_SHAPE, BuildComponent<UIImage>);
 6123        factory.RegisterBuilder((int) CLASS_ID.UI_TEXT_SHAPE, BuildComponent<UIText>);
 24
 6125        factory.createConditions.Add((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE, CanCreateScreenShape);
 6126        factory.createConditions.Add((int) CLASS_ID.UI_FULLSCREEN_SHAPE, CanCreateScreenShape);
 6127    }
 28
 29    bool CanCreateScreenShape(int sceneNumber, int classId)
 30    {
 4431        IParcelScene scene = Environment.i.world.state.GetScene(sceneNumber);
 32
 4433        if (scene.componentsManagerLegacy.GetSceneSharedComponent<UIScreenSpace>() != null)
 034            return false;
 35
 4436        return true;
 37    }
 38
 39
 40    protected T BuildComponent<T>()
 41        where T : IComponent, new()
 42    {
 12243        return new T();
 44    }
 45
 46
 47    public void Dispose()
 48    {
 6149        IRuntimeComponentFactory factory = Environment.i.world.componentFactory;
 50
 6151        factory.UnregisterBuilder((int) CLASS_ID.UI_INPUT_TEXT_SHAPE);
 6152        factory.UnregisterBuilder((int) CLASS_ID.UI_FULLSCREEN_SHAPE);
 6153        factory.UnregisterBuilder((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE);
 6154        factory.UnregisterBuilder((int) CLASS_ID.UI_CONTAINER_RECT);
 6155        factory.UnregisterBuilder((int) CLASS_ID.UI_SLIDER_SHAPE);
 6156        factory.UnregisterBuilder((int) CLASS_ID.UI_CONTAINER_STACK);
 6157        factory.UnregisterBuilder((int) CLASS_ID.UI_IMAGE_SHAPE);
 6158        factory.UnregisterBuilder((int) CLASS_ID.UI_TEXT_SHAPE);
 59
 6160        factory.createConditions.Remove((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE);
 6161        factory.createConditions.Remove((int) CLASS_ID.UI_FULLSCREEN_SHAPE);
 6162    }
 63}