No suggestions in VS code, and log just says "0" no matter what

Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class Control : MonoBehaviour
{

    [SerializeField] InputAction movement;
    // Start is called before the first frame update
    void onEnable()
    {
        movement.Enable();
        
    }

    
    void onDisable() {
        movement.Disable();
    }


    // Update is called once per frame
    void Update()
    {
        float horizontalThrow = movement.ReadValue<Vector2>().x;
        float verticalThrow = movement.ReadValue<Vector2>().y;
        


        // float horizontalThrow = Input.GetAxis("Horizontal");
        // float verticalThrow = Input.GetAxis("Vertical");
        Debug.Log(horizontalThrow);
        Debug.Log(verticalThrow);
        
        
        
    }
}

I have done everything the video has told me to do, and I have tried using a controller and the keyboard, but it just keeps saying “0”.

Also, VS code is not showing suggestions. It has only done this since I started this new project, and was working for Project Boost. It has the basic C# suggestions, but no Unity suggestions like InputManager suggestions or transform.

I have tried restarting, updating, and reloading all the programs - no difference. Also checked that VS code is the external editor and that suggestions are enabled. Also downloaded .NET framework and regenerated csproj files.

I have had this error before, but I just switched to VS code rather than VS to avoid the issue.

I would appreciate any replies,
Flash

P.S: It is called “Control” because I renamed the old file, and was wondering if that was the issue - so I created a new file and just copy + pasted the code.

1 Like

VS code seems to be working now, but I still am getting “0” printed to the console.

Hi,

C# is case-sensitive. If onEnable and onDisable are supposed to get automatically called by Unity, you’ll have to use the correct spelling.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms