Beispiel #1
0
        /// <summary>
        /// Initializes <see cref="AndroidBluetoothMultiplayer"/> class.
        /// Retrieves a pointer to the Java plugin object.
        /// Initalizes the singleton instance on the first usage of the class.
        /// </summary>
        static AndroidBluetoothMultiplayer()
        {
            _plugin            = null;
            _isPluginAvailable = false;

            try {
                UpdateInstance();
            } catch {
                // Happens when this static constructor is called from a GameObject being created.
                // Just ignoring, as this is intended.
            }

#if !UNITY_EDITOR && UNITY_ANDROID
            // Retrieve BluetoothMediator singleton instance
            try {
                using (AndroidJavaClass mediatorClass = new AndroidJavaClass(kPluginClassName)) {
                    if (!mediatorClass.IsNull())
                    {
                        _plugin            = mediatorClass.CallStatic <AndroidJavaObject>("getSingleton");
                        _isPluginAvailable = !_plugin.IsNull();
                    }
                }
            } catch {
                Debug.LogError("AndroidBluetoothMultiplayer initialization failed. Probably .jar not present?");
                throw;
            }
#endif
        }
        /// <summary>
        /// Initializes <see cref="AndroidBluetoothMultiplayer"/> class.
        /// Retrieves a pointer to the Java plugin object.
        /// </summary>
        static AndroidBluetoothMultiplayer()
        {
            _plugin            = null;
            _isPluginAvailable = false;

#if !UNITY_EDITOR && UNITY_ANDROID
            // Retrieve BluetoothMediator singleton instance
            try {
                using (AndroidJavaClass mediatorClass = new AndroidJavaClass(kPluginClassName)) {
                    if (!mediatorClass.IsNull())
                    {
                        _plugin            = mediatorClass.CallStatic <AndroidJavaObject>("getSingleton");
                        _isPluginAvailable = !_plugin.IsNull();
                    }
                }
            } catch {
                Debug.LogError("AndroidBluetoothMultiplayer initialization failed. Probably .aar not present?");
                throw;
            }
#endif
        }