{"id":18238319,"url":"https://github.com/arctop/unity-sdk","last_synced_at":"2025-04-11T12:14:15.011Z","repository":{"id":259525620,"uuid":"878055858","full_name":"arctop/Unity-SDK","owner":"arctop","description":"Arctop SDK for Unity game engine. Native support for iOS \u0026 Android","archived":false,"fork":false,"pushed_at":"2025-04-03T20:50:40.000Z","size":18743,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T21:31:47.533Z","etag":null,"topics":["arctop","bci","sdk","unity"],"latest_commit_sha":null,"homepage":"https://arctop.com","language":"ShaderLab","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arctop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-24T17:45:09.000Z","updated_at":"2025-04-03T20:50:43.000Z","dependencies_parsed_at":"2024-10-26T07:44:12.682Z","dependency_job_id":"022cf623-9a45-4edb-992c-d6e7fbb31a57","html_url":"https://github.com/arctop/Unity-SDK","commit_stats":null,"previous_names":["arctop/unity-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arctop%2FUnity-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arctop%2FUnity-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arctop%2FUnity-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arctop%2FUnity-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arctop","download_url":"https://codeload.github.com/arctop/Unity-SDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248399061,"owners_count":21097295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arctop","bci","sdk","unity"],"created_at":"2024-11-05T03:05:03.229Z","updated_at":"2025-04-11T12:14:14.999Z","avatar_url":"https://github.com/arctop.png","language":"ShaderLab","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arctop® Unity Package\n\nThe Arctop Unity package is a full-fledged SDK allowing access to Arctop's BCI functionality within the Unity ecosystem.\n\nThe plugin currently supports builds for Android and iOS devices, with a mock editor functionality to provide quick iteration.\n\n\u003c!-- TOC --\u003e\n* [Arctop Unity Package](#arctop-unity-package)\n  * [SDK Documentation](#sdk-documentation)\n  * [Installation](#installation)\n  * [General](#general)\n  * [SDK Flow](#sdk-flow)\n  * [Permissions (Android only)](#permissions-android-only)\n  * [Initialization / Destruction](#initialization--destruction)\n  * [Example Project](#example-project)\n  * [Package Components](#package-components)\n    * [ArctopNativeClient](#arctopnativeclient)\n    * [ArctopAndroidSDKPermissionBehaviour](#arctopandroidsdkpermissionbehaviour)\n    * [ArctopSDK](#arctopsdk)\n    * [ArctopNativePlugin](#arctopnativeplugin)\n    * [Listeners / Java Proxies](#listeners--java-proxies)\n  * [Quality Assurance / Signal Quality](#quality-assurance--signal-quality)\n  * [Build Setup](#build-setup)\n    * [Android Setup](#android-setup)\n    * [iOS Setup](#ios-setup)\n\u003c!-- TOC --\u003e\n\n## SDK Documentation\n\nBefore continuing, please first refer to the SDK documentation for [Android](https://github.com/arctop/android-sdk/blob/main/arctopSDK/README.md) or [iOS](https://github.com/arctop/iOS-SDK/blob/main/README.md). These documents provide the basic foundation to understanding the Arctop SDK and the process of utilizing it.\n\nThis Unity SDK guide covers the usage of the Unity plugin that connects to the Arctop SDK for both platforms, and it is imperative that you understand the Arctop SDK's processes beforehand.\n\n## Installation\n\nUse the Unity package manager to add this package from a git url. Refer to the Unity manual for package installation instructions for your specific Unity version.\n\n## General\n\nThe native plugin contains a few pieces under the hood.\n\nInitially, there are the SDK Framework(iOS) / AndroidLib(Android), residing in their respective Plugin folders.\nThose contain the native API for the respective platform.\n\nFor Unity, there are a few key C# scripts:\n\n_ArctopNativePlugin.cs_ is the Unity ↔ Native binding. This class defines all the C / Java bindings and delegates that provide the option to cross the Unity ↔ Native boundary.\n\n_ArctopNativeClient.cs_ is a C# Monobehaviour that provides a wrapper around the native functionality, with a public API and UnityEvents allowing linkage of callbacks from the Editor. This class also provides mock functionality inside the editor, which allows testing in editor without the need to build to device.\n\nThese two classes are the heart of the package. Other classes and their purpose are described later in [this document](#package-components).\n\n## SDK Flow\n\nThe SDK flow is important to understand, and is described in the [documentation above](#sdk-documentation).\n\nTo recap, the flow is Permissions/Binding(Android only) -\u003e Init -\u003e Check login status -\u003e Login -\u003e Check calibration status -\u003e Scan device -\u003e Connect -\u003e Run predictions -\u003e Shut down.\n\n## Permissions (Android only)\n\nThe _ArctopAndroidSDKPermissionBehaviour.cs_ is available to provide handling of the Arctop data permission a user must grant your app before SDK initialization can occur.\nThe behavior is configured to run, create, and initialize the native SDK once permission is granted. Alternatively, you can handle permissions on your own.\n\nSince under the hood the SDK operates as an Android service, the Unity client needs to bind to that service before Initializing.\n\nAll these flows are handled automatically and are provided with callbacks, so you can react to the different states and events within Unity.\n\nOn iOS, this class just calls initialization on the SDK, to allow identical scene setup for both platforms.\n\n## Initialization / Destruction\n\nBefore being able to use any of the SDK’s functionality, there is a need to initialize it.\n\nThe _ArctopNativeClient_ has an API Key field that will need to be filled in order for initialization to succeed.\n\nThere is a checkbox titled “Handle SDK Init”. Having this checked will initialize the SDK on Awake.\nThe other alternative is to use the _ArctopAndroidSDKPermissionBehaviour.cs_ as mentioned [above](#permissions-android-only).\nThe counterpart “Handle SDK Destroy” is also available, which will be called during OnDestroy.\n\nEvery init call needs to be offset by a destroy call. **However**, there is no need to do that in the same scene. This allows having multiple ArctopSDKClient objects in different scenes, and as long as the first one will init and the last one will destroy, the SDK will work. Note that after destruction, an init must be called. There is no limitation on the amount of Init/Destroy pairs that can be called. However, it is important to note that initialization is an expensive process.\n\n![](docs/permissionclient.png)\n\n## Example Project\n\nThe package contains a few examples. \n\nThe main one **Game Example** demonstrates a complete project setup.\nThe scene named **ArctopSDKStartHere** is set up with UI to handle the entire initial setup, following the (Permissions) → Init → Login → Scan → Connect → Start Prediction steps.\n\nOnce Start Prediction is called and succeeds, the app will change scene to the scene that is defined on the ArctopScanController component, on the Scan Panel Object.\n\n![](docs/scancontroller.png)\n\nThe GameWithArctopDemo scene is just a simple UI showing the QA and Values arriving from the prediction. It also provides a finish button and an exit button. The SDK is also destroyed when the scene finishes.\n\nYou can use the example as a reference for scene / project setup.\n\n## Package Components\n\n### ArctopNativeClient\n\nThe native client class / behavior is the entry point and event launcher for all your coding and editor needs with the native plugin.\n\nMost of the functionality is asynchronous and responses from functions will be delivered via events. As events from the native side arrive in different threads, they are put into a queue and are dispatched one at a time at each Update() cycle. This allows the calls to run on Unity’s main thread, retains order of arrival, and makes sure to not clog the main thread with too many calls.\n\nThis means that any function that is invoked in response to an event will be run in a single frame, so consider delegating long-running operations to coroutines or tasks.\n\nCheck the [source file](Runtime/com/arctop/ArctopNativeClient.cs) for this class for documentation of all functions and callbacks.\n\n### ArctopAndroidSDKPermissionBehaviour\n\nThis behavior is used to provide permission handling for Android, and the SDK Creation -\u003e Binding -\u003e Initialization flow for both platforms.\n\n### ArctopSDK\n\nStatic class holding all the response codes, enums, and constants used.\n\n### ArctopNativePlugin\n\nNative plugin bindings for both platforms.\n\n### Listeners / Java Proxies\n\nArctopSDKCallback\n\nArctopSDKSuccessOrFailureCallback\n\nArctopServiceBindCallback\n\nAll these classes are used internally and aren't required for your interactions.\n\n## Quality Assurance / Signal Quality\n\nThe SDK has 2 QA components. During a prediction, it will report a pass/fail and a reason for failure.\nIt is generally good practice to notify the user of these errors.\n\nBefore starting a session, the SDK will evaluate the signal quality of each electrode on the headband.\nIt will report the values at a high rate, and the com.arctop.qa components are available to display a visualization of the data.\n\nYou can use the QASensor prefab as a starting point or as is.\n\nThere is a QA Example available with the isolated prefab in a scene for reference.\n\n\n## Build Setup\n\n### Android Setup\n\nTo successfully build the project for Android, you will need to add a few settings for the manifest and build.gradle files.\n\nIf you do not have your own templates, add those in the publishing settings:\n\n**Player Settings -\u003e Publishing**\n\n![](docs/player-settings.png)\n\nAdd to the Android manifest inside the \u003cmanifest\u003e tags:\n\n    \u003cuses-permission android:name=\"com.arctop.permission.ARCTOP_DATA\" /\u003e\n\nIn the baseProjectTemplate.gradle, add before **BUILD_SCRIPT_DEPS**:\n\n    id \"org.jetbrains.kotlin.jvm\" version \"1.9.20\"\n\nMake sure to verify the correct version for Kotlin and your project.\n\nNext, delete the: \n\n    task clean(type: Delete) {\n    delete rootProject.buildDir\n    }\n\nIn the gradleTemplate.properties, add:\n\n    android.useAndroidX=true\n\nbefore unityStreamingAssets=**STREAMING_ASSETS**.\n\nYou can see an example of the files from the AndroidBuildFiles sample.\n\n### iOS Setup\n\nIn order to make sure that the project embeds Arctop's framework correctly, select your target and, under the build phases, open the \"Embed Frameworks\" section and add ArctopSDK.framework.\n\n![](docs/embedframework.png)\n\nThe SDK requires bluetooth permissions in order to work correctly.\n\nAfter you have built your project and opened it in XCode, add the **Privacy - Bluetooth always usage description** key to your info section of your target, and add a text for the dialog that appears at the start of the app.\n\n![](docs/bluetooth.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farctop%2Funity-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farctop%2Funity-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farctop%2Funity-sdk/lists"}