//
//  BSUPluginUtil.swift
//  UnityFramework
//
//  Created by Moin Hasan on 5/21/25.
//

import UIKit
import BlueStackSDK

@objc(BSUPluginUtil)
public class BSUPluginUtil: NSObject {
    /// Returns the Unity view controller.
    @objc public static func unityGLViewController() -> UIViewController? {
        // If already on main thread, access directly
        if Thread.isMainThread {
            return UIApplication.shared.delegate?.window??.rootViewController
        } else {
            // Otherwise, run synchronously on main thread
            var rootVC: UIViewController?
            DispatchQueue.main.sync {
                rootVC = UIApplication.shared.delegate?.window??.rootViewController
            }
            return rootVC
        }
    }
}
