< Summary

Class:InputAction_Measurable
Assembly:InputController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/InputAction_Measurable.cs
Covered lines:4
Uncovered lines:7
Coverable lines:11
Total lines:50
Line coverage:36.3% (4 of 11)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDCLAction()0%2100%
GetValue()0%2100%
RaiseOnValueChanged(...)0%330100%
OnInspectorGUI()0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/InputAction_Measurable.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4/// <summary>
 5/// An analogical action that raises events when the value is changed. The most common use-case is implementing axis
 6/// </summary>
 7[CreateAssetMenu(fileName = "InputAction_Measurable", menuName = "InputActions/Measurable")]
 8public class InputAction_Measurable : ScriptableObject
 9{
 10    public delegate void ValueChanged(DCLAction_Measurable action, float value);
 11    public event ValueChanged OnValueChanged;
 12
 13    [SerializeField] internal DCLAction_Measurable dclAction;
 014    public DCLAction_Measurable GetDCLAction() => dclAction;
 15
 16    [SerializeField] private float currentValue = 0;
 017    public float GetValue() => currentValue;
 18
 19    internal void RaiseOnValueChanged(float value)
 20    {
 2782021        if (Math.Abs(currentValue - value) > Mathf.Epsilon)
 22        {
 523            currentValue = value;
 524            OnValueChanged?.Invoke(dclAction, currentValue);
 25        }
 2781626    }
 27
 28    #region Editor
 29
 30#if UNITY_EDITOR
 31
 32    [UnityEditor.CustomEditor(typeof(InputAction_Measurable), true)]
 33    internal class InputAction_MeasurableEditor : UnityEditor.Editor
 34    {
 35        private float changeValue = 0;
 36        public override void OnInspectorGUI()
 37        {
 038            DrawDefaultInspector();
 039            changeValue = GUILayout.HorizontalSlider(changeValue, 0, 1);
 040            if (Application.isPlaying && GUILayout.Button("Raise OnChange"))
 41            {
 042                ((InputAction_Measurable)target).RaiseOnValueChanged(changeValue);
 43            }
 044        }
 45    }
 46#endif
 47
 48    #endregion
 49
 50}