BrainBit for developers Subscribe for updates Visit website

Unity

    
public sealed class BuilderPostProcessor
{
    [PostProcessBuild(1)]
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
#if UNITY_IOS
        if (target == BuildTarget.iOS)
        {
            var infoPlist = new PlistDocument();
            var infoPlistPath = path + "/Info.plist";
            infoPlist.ReadFromFile(infoPlistPath);

            PlistElementDict dict = infoPlist.root.AsDict();
            dict.SetString("NSBluetoothAlwaysUsageDescription", "App requires access to Bluetooth to allow you connect to device");
            dict.SetString("NSBluetoothPeripheralUsageDescription", "App uses Bluetooth to connect with your Brainbit device");
            infoPlist.WriteToFile(infoPlistPath);
        }
#endif
    }
}
    

The latest version is `1.0.6.17`.

Available for iOS, Android, Windows, MacOS platforms

1. Open Package Manager
2. Click "Add" menu and choose "Add package from GIT url...". A text box and an Add button appear.
3. Enter a "https://github.com/BrainbitLLC/unity_neurosdk2.git" in the text box and click Add.

 

If Unity was able to install the package successfully, the package now appears in the package list with the tag. If Unity was not able to install the package, the Unity Console displays an error message.

 

For Android platform ask for Bluetooth and Location permission before use:

    
#if UNITY_ANDROID
        Permission.RequestUserPermission("android.permission.BLUETOOTH_SCAN");
        Permission.RequestUserPermission("android.permission.BLUETOOTH_CONNECT");
        Permission.RequestUserPermission("android.permission.BLUETOOTH");
        Permission.RequestUserPermission("android.permission.BLUETOOTH_ADMIN");
        Permission.RequestUserPermission("android.permission.ACCESS_FINE_LOCATION");
        Permission.RequestUserPermission("android.permission.ACCESS_COARSE_LOCATION");
        Permission.RequestUserPermission("android.permission.ACCESS_BACKGROUND_LOCATION");
#endif
    

 

For iOS/MacOs you need to add a key to `Info.plist` because it uses bluetooth too:

    
public sealed class BuilderPostProcessor
{
    [PostProcessBuild(1)]
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
#if UNITY_IOS
        if (target == BuildTarget.iOS)
        {
            var infoPlist = new PlistDocument();
            var infoPlistPath = path + "/Info.plist";
            infoPlist.ReadFromFile(infoPlistPath);

            PlistElementDict dict = infoPlist.root.AsDict();
            dict.SetString("NSBluetoothAlwaysUsageDescription", "App requires access to Bluetooth to allow you connect to device");
            dict.SetString("NSBluetoothPeripheralUsageDescription", "App uses Bluetooth to connect with your Brainbit device");
            infoPlist.WriteToFile(infoPlistPath);
        }
#endif
    }
}