C# cant find a class auto generated by unity
Okay so I'm learning to use the new InputActions and I've created a C# scripts using
And this is what I got:
// GENERATED AUTOMATICALLY FROM 'Assets/PlayerControls.inputactions'
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public class PlayerControls : IInputActionCollection
{
private InputActionAsset asset;
public PlayerControls()
{
///
}
}
But when I try to create an PlayerControls object, I get an error saying
The type or namespace name 'PlayerControls' could not be found (are you missing a using directive or an assembly reference?)
This is the class where I try to reference it:
using System;
using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;
using UnityEngine.InputSystem;
namespace UnityStandardAssets.Characters.FirstPerson
{
public class FirstPersonController : MonoBehaviour
{
private PlayerControls controls; // ERROR HERE
}
}
Just checked, I can't reference any of the scripts I made in the global namespace from the FirstPersonController class
Answer by domdimmadough · Sep 29, 2020 at 10:59 AM
got to assets, select the input action importer you made in order to assign actions. you will see the option to generate C# Class. check the box and look for the class name in the inspector, whatever is written there is to be used in place of Player.Controls
Answer by Bunny83 · Sep 28, 2020 at 10:02 PM
Well I never used any of the standard assets, but usually they are placed in the first pass compilation group and therefore are compiled seperately from your normal classes. Standard assets are not meant to be edited / modified. If you want to modify such an asset, move it outside the Standard Assets folder and outside the plugins folder which belong to the first pass compilation group.
For more information see the documentation on special folders and compilation groups.