< Summary

Class:DCL.RenderProfileManifest
Assembly:RenderProfiles
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/Profiles/RenderProfileManifest.cs
Covered lines:14
Uncovered lines:3
Coverable lines:17
Total lines:66
Line coverage:82.3% (14 of 17)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetOrLoad[T](...)0%220100%
Initialize(...)0%4.374071.43%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/Profiles/RenderProfileManifest.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.ComponentModel;
 5using UnityEngine;
 6using Object = UnityEngine.Object;
 7
 8namespace DCL
 9{
 10    /// <summary>
 11    /// RenderProfileManifest is used to store and set the current used RenderProfileWorld.
 12    ///
 13    /// When a new RenderProfileWorld object is added to the project it must be added here as well.
 14    /// </summary>
 15    [CreateAssetMenu(menuName = "DCL/Rendering/Render Profile Manifest", fileName = "RenderProfileManifest", order = 0)]
 16    public class RenderProfileManifest : ScriptableObject
 17    {
 18        private static RenderProfileManifest instance;
 212419        public static RenderProfileManifest i => GetOrLoad(ref instance, "Render Profile Manifest");
 20
 21        public RenderProfileWorld defaultProfile;
 22        public RenderProfileWorld nightProfile;
 23        public RenderProfileWorld testProfile;
 24
 25        private RenderProfileWorld currentProfileValue;
 26
 27        public RenderProfileWorld currentProfile
 28        {
 029            get { return currentProfileValue; }
 30            set
 31            {
 66632                if (value == null || value == currentProfileValue)
 64933                    return;
 34
 1735                currentProfileValue = value;
 1736                OnChangeProfile?.Invoke(value);
 1637            }
 38        }
 39
 40        public event Action<RenderProfileWorld> OnChangeProfile;
 41
 42        internal static T GetOrLoad<T>(ref T variable, string path) where T : Object
 43        {
 212444            if (variable == null)
 45            {
 246                variable = Resources.Load<T>(path);
 47            }
 48
 212449            return variable;
 50        }
 51
 52        public void Initialize(RenderProfileWorld initProfile = null)
 53        {
 66654            currentProfile = initProfile != null ? initProfile : defaultProfile;
 55
 66656            if (currentProfile == null)
 57            {
 058                Debug.Log("Default profile should never be null!");
 059                return;
 60            }
 61
 66662            currentProfile.avatarProfile.currentProfile = currentProfile.avatarProfile.inWorld;
 66663            currentProfile.Apply();
 66664        }
 65    }
 66}