Rune580 / LethalCompanyInputUtils

GNU Lesser General Public License v3.0
12 stars 5 forks source link

InputAction not working #39

Closed 2duviz2 closed 3 months ago

2duviz2 commented 3 months ago

I'm completly sure that i'm doing something wrong, but I can't get InputAction to work. I'm using v0.7.1 (the lastest) I also tried with v0.6.2, the same happens

Here's my code:

//References
using LethalCompanyInputUtils.Api;
using LethalCompanyInputUtils;

namespace Nose
{
    [BepInPlugin(pluginGuid, pluginName, pluginVersion)]
    [BepInDependency("com.rune580.LethalCompanyInputUtils", BepInDependency.DependencyFlags.HardDependency)]
    public class NoseMod : BaseUnityPlugin
    {
        //Code

        public static InputController InputActionsInstance;

        public void Awake()
        {
            //Code

            InputActionsInstance = new InputController();
        }
    }

    public class NosePatch
    {
        [HarmonyPostfix]
        public static void UpdatePCB(GameNetcodeStuff.PlayerControllerB __instance)
        {
                  //code
        }
        public void SetupKeybindCallbacks()
        {
            NoseMod.InputActionsInstance.CheatsKey .performed += OnExplodeKeyPressed
        }

        public void OnExplodeKeyPressed(InputAction.CallbackContext ctx)
        {
            // Your executing code here
        }
    }

    public class InputController : LcInputActions
    {
        [InputAction("<Keyboard>/r", Name = "Cheats")]

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        public InputAction  CheatsKey { get; set; } // <- INPUTACTION DOESN'T WORK
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }
}

The problem is that I can't reference InputAction, I tried with InputActionAttribute but it just doesn't work.

Rune580 commented 3 months ago

Did you end up finding a solution?

2duviz2 commented 3 months ago

I forgot to import the InputSystem

using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

Was the solution for me