- Home /
Question by
B3nji_ · Jan 30 at 12:02 AM ·
scripting probleminspector
Script reference not showing in inspector
So i have a script generated automatically from the unity's input system, that i called InputMaster. But when i try to reference the script:
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public InputMaster controls;
}
It doesn't show up in the inspector!
Not even in debug mode...
here is the InputMaster code in case you need it
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public partial class @InputMaster : IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @InputMaster()
{
asset = InputActionAsset.FromJson(@
"{
//100% not the problem here, these are just assets
}");
// Player
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
m_Player_Movement = m_Player.FindAction("Movement", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
public IEnumerable<InputBinding> bindings => asset.bindings;
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
public int FindBinding(InputBinding bindingMask, out InputAction action)
{
return asset.FindBinding(bindingMask, out action);
}
// Player
private readonly InputActionMap m_Player;
private IPlayerActions m_PlayerActionsCallbackInterface;
private readonly InputAction m_Player_Movement;
public struct PlayerActions
{
private @InputMaster m_Wrapper;
public PlayerActions(@InputMaster wrapper) { m_Wrapper = wrapper; }
public InputAction @Movement => m_Wrapper.m_Player_Movement;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); }
public void SetCallbacks(IPlayerActions instance)
{
if (m_Wrapper.m_PlayerActionsCallbackInterface != null)
{
@Movement.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnMovement;
@Movement.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnMovement;
@Movement.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnMovement;
}
m_Wrapper.m_PlayerActionsCallbackInterface = instance;
if (instance != null)
{
@Movement.started += instance.OnMovement;
@Movement.performed += instance.OnMovement;
@Movement.canceled += instance.OnMovement;
}
}
}
public PlayerActions @Player => new PlayerActions(this);
private int m_KeyboardandMouseSchemeIndex = -1;
public InputControlScheme KeyboardandMouseScheme
{
get
{
if (m_KeyboardandMouseSchemeIndex == -1) m_KeyboardandMouseSchemeIndex = asset.FindControlSchemeIndex("Keyboard and Mouse");
return asset.controlSchemes[m_KeyboardandMouseSchemeIndex];
}
}
private int m_GamepadSchemeIndex = -1;
public InputControlScheme GamepadScheme
{
get
{
if (m_GamepadSchemeIndex == -1) m_GamepadSchemeIndex = asset.FindControlSchemeIndex("Gamepad");
return asset.controlSchemes[m_GamepadSchemeIndex];
}
}
public interface IPlayerActions
{
void OnMovement(InputAction.CallbackContext context);
}
}
dacancellare.png
(4.8 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613052332im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it ok to use nested classes, to cache and access components? 1 Answer
AudioSource 1 Answer
Why is my Unity script overwriting other game objects on which it is attached to? 1 Answer
Display the same string in multiple text boxes 1 Answer
Best way to defining scripts within a list inside the editor? 1 Answer