Same input manager across scenes

I’m making an RPG, with several Scenes. Throughout the entire game, I want ONE input manager (GameObject with player input component). If I add them to multiple objects, the action maps are all odd. Can I make an input manager in one GameObject which is accessed by every other GameObject across every scene? If not, how can I use multiple GameObjects with the ‘Player Input’ component?

I mainly use Visual Scripting, but C# is fine.

Any help greatly appreciated!

Make it DontDestroyOnLoad: Unity - Scripting API: Object.DontDestroyOnLoad

Namely, don’t put it on any scenes, but when the application starts or you enter play mode, have it load itself from Resources or Addressables and remain there for the duration of the application.

Thanks for the reply, how do I make it load itself from Resources or Addressables?

I’d use this attribute on a static method: Unity - Scripting API: RuntimeInitializeOnLoadMethodAttribute

Thus once you enter play mode, the code runs, and you can use that to load and instantiate the input manager.

I figured it out in the end. Just make a GameObject in any scene, attach a playerInput to any scene, and add a script. All you need in the script is:

using UnityEngine;
public class DontDestroyOnLoad : MonoBehaviour
{void Start() {DontDestroyOnLoad(gameObject);}}

Then set an application variable the GameObject, and retrieve that variable whenever you use an input system in another scene.