简体   繁体   中英

issue importing UnityEngine.InputSystem. Error CS0246 type or namespace not found

despite having copied the code of a tutorial exactly, i'm being unable to run my code.

this is the video. the code can be seen in 11:37.

i installed unity 2 or 3 days ago, so i doubt it is an update issue (i saw someone on another thread saying this)

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

public class controle : MonoBehaviour
{
private PlayerControls controls;  // the error points at this line, at whatever position the "PlayerControls" string is

private void Awake()
{
    controls = new PlayerControls();
    controls.Gameplay.Forward.performed += Forward;
}


void Forward()
{
    transform.position.z -= 1.1 * f;

}

void OnEnable()
{
    controls.Gameplay.Enable();
}

void OnDisable()
{
    controls.Gameplay.Disable();

}


}

This could possibly be because of a compiler order issue; your controle class might be compiled before PlayerControls exists and therefore it can't access it.
Here is an example this .
Check if you put your file in the Standard Assets folder, as files there are compiled before all the other class scripts.
You can read more here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM