using System;
using UnityEngine;
using UnityEngine.EventSystems;

namespace MajacloudSdk.Samples.Starter
{
    /// <summary>Adds the right input module at runtime so the sample works with the legacy Input Manager or the Input System package.</summary>
    [RequireComponent(typeof(EventSystem))]
    public sealed class InputModuleBootstrap : MonoBehaviour
    {
        private void Awake()
        {
            if (GetComponent<BaseInputModule>() != null) return;
#if ENABLE_LEGACY_INPUT_MANAGER
            gameObject.AddComponent<StandaloneInputModule>();
#else
            var type = Type.GetType("UnityEngine.InputSystem.UI.InputSystemUIInputModule, Unity.InputSystem");
            if (type != null) gameObject.AddComponent(type);
            else Debug.LogWarning("[Majacloud Starter] No input module available: enable the legacy Input Manager or install the Input System package.");
#endif
        }
    }
}
