using UnityEngine;
using UnityEditor;

/** not really used **/
public class PopupApi : PopupWindowContent
{

    public override Vector2 GetWindowSize()
    {
        return new Vector2(200, 150);
    }

    public override void OnGUI(Rect rect)
    {
        GUILayout.Label("API Settings", EditorStyles.boldLabel);

        var group = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
        var api = PlayerSettings.GetApiCompatibilityLevel(group);
        if (api != ApiCompatibilityLevel.NET_4_6)
        {
            GUILayout.Label("MongoDB requires .NET 4.x to build and the current setting is different.");
            GUILayout.Label("Do you want to change to .NET 4.x?");
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Yes"))
            {
                PlayerSettings.SetApiCompatibilityLevel(group, ApiCompatibilityLevel.NET_4_6);
                editorWindow.Close();
            }
            if (GUILayout.Button("No"))
            {
                editorWindow.Close();
            }
            EditorGUILayout.EndHorizontal();
        }

        
    }

    public override void OnOpen()
    {
        Debug.Log("Popup opened: " + this);
    }

    public override void OnClose()
    {
        Debug.Log("Popup closed: " + this);
    }
}