Basic UI Example
This example is a basic “hello-world” example. In playmode, the device will automatically connect to any Skinetic device available, and update the connection status. Additionally, two buttons are displayed in the middle of the screen, pressing one of them triggers a predefined haptic effect on the vest on the front (or back) of the haptic device.
The scene is composed of a canvas with two buttons and a text and an empty gameobject SkineticBasicUIExample containing two gameobjects: one to handle the
SkineticDevice component and one to handle the
The connection is automatically performed by the SkiEx_AutoConnect script on the
SkineticDevice component. This script has a reference set in the inspector to the
SkineticDevice component and a Text on the canvas.
On the OnEnable event
A connection callback is set:
This callback will be called whenever the connection to the device is made or broken, and update the state string
m_connectString. When the connection succeed, the serial number is passed as an argument to the callback, it can be converted to a formatted string using the static
A connection to any Skinetic device is requested by passing
Skinetic.SkineticDevice.OutputType.E_AUTODETECTto allow any kind of connection and 0 to pick the first available device.
Start a coroutine to update the connection status in the text field as the callback being called from another thread cannot update the UI itself.
During the OnDisable event
The disconnection routine is initiated and the function returns once the disconnection is completed.
The HapticEffects gameobject contains 3 components:
HapticEffectcomponents whose parameters are predefined in the inspector and hold references to the
SkineticDevicecomponent in the scene and to the
PatternAssetScriptableObject they have to use.
a SkiEx_BasicUIEffects script which simply holds reference to the two
HapticEffectand exposes 2 public functions registered in the inspector to each button’s
OnClick()event. These functions then call
HapticEffectas the target device was set in the inspector.
Additionally, the two
PatternAsset ScriptableObjects are added to the preload list of the
SkineticDevice so there is no need to register them through scripting as they will be loaded right at the beginning.