< Summary

Class:SmartItemOptionsParameter
Assembly:BuilderInWorldEntityInformation
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/EntityInformation/SmartItems/Parameters/SmartItemOptionsParameter.cs
Covered lines:0
Uncovered lines:16
Coverable lines:16
Total lines:45
Line coverage:0% (0 of 16)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%2100%
SetInfo()0%20400%
OnValueChange(...)0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/EntityInformation/SmartItems/Parameters/SmartItemOptionsParameter.cs

#LineLine coverage
 1using DCL.Components;
 2using System;
 3using System.Collections;
 4using System.Collections.Generic;
 5using TMPro;
 6using UnityEngine;
 7
 8public class SmartItemOptionsParameter : SmartItemUIParameterAdapter
 9{
 10    public TMP_Dropdown dropDown;
 11
 012    private void Start() { dropDown.onValueChanged.AddListener(OnValueChange); }
 13
 14    public override void SetInfo()
 15    {
 016        base.SetInfo();
 17
 018        dropDown.options = new List<TMP_Dropdown.OptionData>();
 19
 020        List<string> optionsLabelList = new List<string>();
 021        foreach (SmartItemParameter.OptionsParameter options in currentParameter.options)
 22        {
 023            optionsLabelList.Add(options.label);
 24        }
 25
 026        dropDown.AddOptions(optionsLabelList);
 27
 028        string value = (string) GetParameterValue();
 29
 030        for (int i = 0; i < currentParameter.options.Length; i++)
 31        {
 032            if (currentParameter.options[i].value == value)
 033                dropDown.SetValueWithoutNotify(i);
 34        }
 035    }
 36
 37    private void OnValueChange(int currentIndex)
 38    {
 039        foreach (SmartItemParameter.OptionsParameter options in currentParameter.options)
 40        {
 041            if (options.label == dropDown.options[currentIndex].text)
 042                SetParameterValue(options.value);
 43        }
 044    }
 45}