< Summary

Class:InputAction_Hold
Assembly:InputController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/InputAction_Hold.cs
Covered lines:6
Uncovered lines:8
Coverable lines:14
Total lines:56
Line coverage:42.8% (6 of 14)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDCLAction()0%2100%
RaiseOnStarted()0%220100%
RaiseOnFinished()0%220100%
OnInspectorGUI()0%30500%

File(s)

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

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4/// <summary>
 5/// An on/off action that triggers Start when the input is read and Finished when the input has gone
 6/// </summary>
 7[CreateAssetMenu(fileName = "InputAction_Hold", menuName = "InputActions/Hold")]
 8public class InputAction_Hold : ScriptableObject
 9{
 10    public delegate void Started(DCLAction_Hold action);
 11    public delegate void Finished(DCLAction_Hold action);
 12    public event Started OnStarted;
 13    public event Finished OnFinished;
 14
 15    [SerializeField] internal DCLAction_Hold dclAction;
 016    public DCLAction_Hold GetDCLAction() => dclAction;
 17
 018    public bool isOn { get; private set; }
 19
 20    public void RaiseOnStarted()
 21    {
 722        isOn = true;
 723        OnStarted?.Invoke(dclAction);
 324    }
 25
 26    public void RaiseOnFinished()
 27    {
 3628        isOn = false;
 3629        OnFinished?.Invoke(dclAction);
 3430    }
 31
 32    #region Editor
 33
 34#if UNITY_EDITOR
 35
 36    [UnityEditor.CustomEditor(typeof(InputAction_Hold), true)]
 37    internal class InputAction_HoldEditor : UnityEditor.Editor
 38    {
 39        public override void OnInspectorGUI()
 40        {
 041            DrawDefaultInspector();
 042            if (Application.isPlaying && GUILayout.Button("Raise OnStarted"))
 43            {
 044                ((InputAction_Hold)target).RaiseOnStarted();
 45            }
 046            if (Application.isPlaying && GUILayout.Button("Raise OnFinished"))
 47            {
 048                ((InputAction_Hold)target).RaiseOnFinished();
 49            }
 050        }
 51    }
 52#endif
 53
 54    #endregion
 55
 56}