< Summary

Class:DCL.RenderProfileAvatar
Assembly:RenderProfiles
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/Profiles/RenderProfileAvatar.cs
Covered lines:11
Uncovered lines:4
Coverable lines:15
Total lines:66
Line coverage:73.3% (11 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Apply(...)0%2.262060%
CheckAndAssignCurrentProfile()0%220100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using DCL.Helpers;
 5using UnityEngine;
 6using UnityEngine.Serialization;
 7
 8namespace DCL
 9{
 10    /// <summary>
 11    /// This ScriptableObject is used to control toon shader and avatar rendering values
 12    /// assigned to any RenderProfileWorld.
 13    ///
 14    /// Values can change depending if we are in avatar editor mode or in-game world.
 15    /// </summary>
 16    [CreateAssetMenu(menuName = "DCL/Rendering/Create Avatar Profile", fileName = "RenderProfileAvatar", order = 0)]
 17    public class RenderProfileAvatar : ScriptableObject
 18    {
 19        [System.Serializable]
 20        public class MaterialProfile
 21        {
 22            [SerializeField] internal Color tintColor;
 23            [SerializeField] internal Color lightColor;
 24            [SerializeField] internal Vector3 lightDirection;
 25        }
 26
 27        [NonSerialized] public MaterialProfile currentProfile;
 28
 29        public MaterialProfile avatarEditor;
 30
 31        public MaterialProfile inWorld;
 32
 33        /// <summary>
 34        /// Applies the material profile.
 35        /// </summary>
 36        /// <param name="targetMaterial">If target material is null, the properties will be applied globally.</param>
 37        public void Apply(Material targetMaterial = null)
 38        {
 80339            CheckAndAssignCurrentProfile();
 40
 80341            if (targetMaterial != null)
 42            {
 043                targetMaterial.SetVector(ShaderUtils.LightDir, currentProfile.lightDirection);
 044                targetMaterial.SetColor(ShaderUtils.LightColor, currentProfile.lightColor);
 045                targetMaterial.SetColor(ShaderUtils.TintColor, currentProfile.tintColor);
 046                return;
 47            }
 48
 80349            Shader.SetGlobalVector(ShaderUtils.LightDir, currentProfile.lightDirection);
 80350            Shader.SetGlobalColor(ShaderUtils.LightColor, currentProfile.lightColor);
 80351            Shader.SetGlobalColor(ShaderUtils.TintColor, currentProfile.tintColor);
 80352        }
 53
 54        public void CheckAndAssignCurrentProfile()
 55        {
 147456            if (DataStore.i.skyboxConfig.avatarMatProfile.Get() == AvatarMaterialProfile.InWorld)
 57            {
 139158                currentProfile = inWorld;
 139159            }
 60            else
 61            {
 8362                currentProfile = avatarEditor;
 63            }
 8364        }
 65    }
 66}