< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Apply(...)0%3.843054.55%

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        {
 74639            if (currentProfile == null)
 040                currentProfile = inWorld;
 41
 74642            if (targetMaterial != null)
 43            {
 044                targetMaterial.SetVector(ShaderUtils.LightDir, currentProfile.lightDirection);
 045                targetMaterial.SetColor(ShaderUtils.LightColor, currentProfile.lightColor);
 046                targetMaterial.SetColor(ShaderUtils.TintColor, currentProfile.tintColor);
 047                return;
 48            }
 49
 74650            Shader.SetGlobalVector(ShaderUtils.LightDir, currentProfile.lightDirection);
 74651            Shader.SetGlobalColor(ShaderUtils.LightColor, currentProfile.lightColor);
 74652            Shader.SetGlobalColor(ShaderUtils.TintColor, currentProfile.tintColor);
 74653        }
 54    }
 55}

Methods/Properties

Apply(UnityEngine.Material)