< Summary

Class:UIRainbowController
Assembly:Assembly-CSharp
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/UI/Rainbow/UIRainbowController.cs
Covered lines:32
Uncovered lines:6
Coverable lines:38
Total lines:98
Line coverage:84.2% (32 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UIRainbowController()0%110100%
Start()0%2.52050%
FixedUpdate()0%220100%
SetValues()0%5.025090.62%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/UI/Rainbow/UIRainbowController.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public class UIRainbowController : MonoBehaviour
 7{
 8    Material targetMat;
 9    public Image img;
 10    public Texture mask;
 11    public bool useTexture;
 12    public Texture gradientTexture;
 13    public Gradient gradient;
 14    public Vector2 speed;
 15    [Range(-360, 360)]
 16    public float rotation;
 17    [Range(0,1)]
 13418    public float fill = 1f;
 19
 20    public enum rainbowT {linear, radial};
 21    public enum fillT {left, right, up, down};
 22
 23    public rainbowT rainbowType;
 24    public fillT fillType;
 25
 26    void Start()
 27    {
 12228        if(img.maskable)
 29        {
 12230            targetMat = img.materialForRendering;
 12231        }
 32        else
 33        {
 034            targetMat = new Material(img.material);
 035            img.material = targetMat;
 36        }
 037    }
 38
 39
 40    void FixedUpdate()
 41    {
 46242        if(targetMat)
 43        {
 46244            SetValues();
 45        }
 46
 46247    }
 48
 49    void SetValues()
 50    {
 46251        targetMat.SetTexture("_Mask", mask);
 46252        targetMat.SetTexture("_Ramp", gradientTexture);
 46253        targetMat.SetVector("_Speed", speed);
 46254        targetMat.SetFloat("_Rotation", rotation);
 46255        targetMat.SetFloat("_Fill", fill);
 56
 46257        if (useTexture)
 58        {
 059            targetMat.SetFloat("_UseTexture", 1);
 060        }
 61        else
 62        {
 46263            targetMat.SetFloat("_UseTexture", 0);
 64        }
 65
 46266        targetMat.SetFloat("_GradientMode", ((int)rainbowType));
 46267        targetMat.SetFloat("_FillDirection", ((int)fillType));
 68
 46269        targetMat.SetFloat("_ColorAmount", gradient.colorKeys.Length);
 70
 46271        float[] tempPos01 = new float[4];
 46272        float[] tempPos02 = new float[4];
 73
 462074        for (int i = 0; i < 4; i++)
 75        {
 184876            tempPos01[i] = 1;
 184877            tempPos02[i] = 1;
 78        }
 79
 462080        for (int i = 0; i < gradient.colorKeys.Length; i++)
 81        {
 184882            targetMat.SetColor("_Color0" + (i + 1).ToString(), gradient.colorKeys[i].color);
 184883            if (i <= 3)
 84            {
 184885                tempPos01[i] = gradient.colorKeys[i].time;
 184886            }
 87            else
 88            {
 089                tempPos02[i - 4] = gradient.colorKeys[i].time;
 90            }
 91        }
 46292        Vector4 pos01 = new Vector4(tempPos01[0], tempPos01[1], tempPos01[2], tempPos01[3]);
 46293        Vector4 pos02 = new Vector4(tempPos02[0], tempPos02[1], tempPos02[2], tempPos02[3]);
 94
 46295        targetMat.SetVector("_GradientPositions01", pos01);
 46296        targetMat.SetVector("_GradientPositions02", pos02);
 46297    }
 98}