< 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:9
Uncovered lines:6
Coverable lines:15
Total lines:59
Line coverage:60% (9 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
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;
 14965116    public DCLAction_Hold DCLAction => dclAction;
 17
 818    public bool isOn { get; private set; }
 19
 20    [SerializeField] internal BooleanVariable holdBlocked;
 16461521    public BooleanVariable isHoldBlocked { get => holdBlocked; set => holdBlocked = value; }
 22
 23    public void RaiseOnStarted()
 24    {
 325        isOn = true;
 326        OnStarted?.Invoke(dclAction);
 127    }
 28
 29    public void RaiseOnFinished()
 30    {
 231        isOn = false;
 232        OnFinished?.Invoke(dclAction);
 133    }
 34
 35    #region Editor
 36
 37#if UNITY_EDITOR
 38
 39    [UnityEditor.CustomEditor(typeof(InputAction_Hold), true)]
 40    internal class InputAction_HoldEditor : UnityEditor.Editor
 41    {
 42        public override void OnInspectorGUI()
 43        {
 044            DrawDefaultInspector();
 045            if (Application.isPlaying && GUILayout.Button("Raise OnStarted"))
 46            {
 047                ((InputAction_Hold)target).RaiseOnStarted();
 48            }
 049            if (Application.isPlaying && GUILayout.Button("Raise OnFinished"))
 50            {
 051                ((InputAction_Hold)target).RaiseOnFinished();
 52            }
 053        }
 54    }
 55#endif
 56
 57    #endregion
 58
 59}