< Summary

Class:DCL.Skybox.MaterialReferenceContainer
Assembly:ProceduralSkybox
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/MaterialReferenceContainer.cs
Covered lines:0
Uncovered lines:12
Coverable lines:12
Total lines:56
Line coverage:0% (0 of 12)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetOrLoad[T](...)0%6200%
GetMaterialForLayers(...)0%12300%
GetMat_LayerForLayers(...)0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/MaterialReferenceContainer.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5namespace DCL.Skybox
 6{
 7    [CreateAssetMenu(fileName = "SkyboxMaterialData", menuName = "ScriptableObjects/SkyboxMaterialData", order = 1)]
 8    public class MaterialReferenceContainer : ScriptableObject
 9    {
 10        [System.Serializable]
 11        public class Mat_Layer
 12        {
 13            public int numberOfSlots;
 14            public Material material;
 15        }
 16
 17        private static MaterialReferenceContainer instance;
 018        public static MaterialReferenceContainer i => GetOrLoad(ref instance, "Skybox Materials/SkyboxMaterialData");
 19
 20        private static T GetOrLoad<T>(ref T variable, string path) where T : Object
 21        {
 022            if (variable == null)
 23            {
 024                variable = Resources.Load<T>(path);
 25            }
 26
 027            return variable;
 28        }
 29
 30        public Mat_Layer[] materials;
 31
 32        public Material GetMaterialForLayers(int numOfLayer)
 33        {
 034            for (int i = 0; i < materials.Length; i++)
 35            {
 036                if (numOfLayer <= materials[i].numberOfSlots)
 37                {
 038                    return materials[i].material;
 39                }
 40            }
 041            return null;
 42        }
 43
 44        public Mat_Layer GetMat_LayerForLayers(int numOfSlots)
 45        {
 046            for (int i = 0; i < materials.Length; i++)
 47            {
 048                if (numOfSlots <= materials[i].numberOfSlots)
 49                {
 050                    return materials[i];
 51                }
 52            }
 053            return null;
 54        }
 55    }
 56}