- Home /
Class variable wont show up in inspector with new Unity Input System
The c# script that is generated from the new Input System cannot be assigned to a variable in a monobehaviour script. The field does not show up in the inspector, regardless of whether its public or serialized. There are no compile errors or namespace conflicts. I'm on Unity 2019.1.12f1 and the most recent version of InputSystem.
What's strange is that the class is still recognized as a valid class type. Any thoughts on what could be causing this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Input$$anonymous$$ethods : $$anonymous$$onoBehaviour
{
public TestInput testControls; //doesn't show up in inspector
void Awake()
{
testControls.Enable();
testControls.Character.Attack.performed += context => Attack();
}
void Attack()
{
Debug.Log("Attack");
}
}
Answer by CRYWOLF86 · Aug 04, 2019 at 01:59 PM
In case anyone else needs the solution; This is actually intended behavior on Unity's part. You have to initialize. You can no longer drag the file into the inspector as they changed the backend. You can just do controls = new MyGeneratedInputScript(); in awake to create a new instance of the object.
Your answer
Follow this Question
Related Questions
Serialising subclass variables in inspector 2 Answers
Saving class data without having lots of references? 1 Answer
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Unity Serialization with XML Root problem: 'Does Not Denote Valid Type' 0 Answers
Save an array with custom classes 1 Answer