I’m wondering how to synchronize the InputActionAsset class with the InputActions (the class created in Unity by creating Input Actions and using the Generate C# Class method).
In My Project,
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : Singleton<InputManager>
{
public InputActionAsset inputActionAsset; // 인스펙터에서 참조 설정
public InputActions inputActions;
protected override void OnSingletonAwake()
{
// InputActions 생성 및 초기화
inputActions = new InputActions();
inputActions.asset = inputActionsAsset;
inputActions.Enable(); // 기본적으로 모든 액션 활성화
}
public InputActions.PlayerActions GetPlayerActions()
{
return inputActions.Player;
}
public InputActions.UIActions GetUIActions()
{
return inputActions.UI;
}
// 상태에 따라 PlayerInput 활성화/비활성화
public void SetPlayerInputActive(bool isActive)
{
if (isActive)
{
inputActions.Player.Enable();
inputActions.UI.Disable();
}
else
{
inputActions.Player.Disable();
inputActions.UI.Enable();
}
}
}
At first, I tried to synchronize with the code in the 16th line of the above method,
To use this method, I need to modify the C# Generate Class.
However, it seems like a dangerous way to touch the class automatically generated by Unity. I feel like it will lead to unexpected results…
So I wonder how seniors synchronize in this situation.