< 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:7
Uncovered lines:5
Coverable lines:12
Total lines:53
Line coverage:58.3% (7 of 12)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetValue()0%110100%
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;
 7482614    public DCLAction_Measurable DCLAction => dclAction;
 15
 16    [SerializeField] private float currentValue = 0;
 5992317    public float GetValue() => currentValue;
 18
 19    [SerializeField] internal BooleanVariable blockMeasurable;
 10475520    public BooleanVariable isMeasurableBlocked { get => blockMeasurable; set => blockMeasurable = value; }
 21
 22    internal void RaiseOnValueChanged(float value)
 23    {
 7483024        if (Math.Abs(currentValue - value) > Mathf.Epsilon)
 25        {
 526            currentValue = value;
 527            OnValueChanged?.Invoke(dclAction, currentValue);
 28        }
 7482629    }
 30
 31    #region Editor
 32
 33#if UNITY_EDITOR
 34
 35    [UnityEditor.CustomEditor(typeof(InputAction_Measurable), true)]
 36    internal class InputAction_MeasurableEditor : UnityEditor.Editor
 37    {
 38        private float changeValue = 0;
 39        public override void OnInspectorGUI()
 40        {
 041            DrawDefaultInspector();
 042            changeValue = GUILayout.HorizontalSlider(changeValue, 0, 1);
 043            if (Application.isPlaying && GUILayout.Button("Raise OnChange"))
 44            {
 045                ((InputAction_Measurable)target).RaiseOnValueChanged(changeValue);
 46            }
 047        }
 48    }
 49#endif
 50
 51    #endregion
 52
 53}