Description:
This Unity plug-in can be applied to the iOS platform to realize the function of connecting Lovense toys and sending control commands.
Compatibility:
Unity version > 2018.4.0
Scripting Backend: Mono
Api Compatibility Level: *For .Net 4.x the import name is “*_Net4.x*.unitypackage”.
Api Compatibility Level: *For .NetFramework the imported package name is “*.NetFramework*.unitypackage”.
Api Compatibility Level: *For .NetStandard2.1 the imported package name is “*.NetStandard2.1*.unitypackage”
Api Compatibility Level: *For .NetStandard2.0 the imported package name is “*.NetStandard2.0*.unitypackage”
Steps to integrate the plugin:
-
Import the appropriate package based on your project’s Api Compatibility Level*.
-
Select all options and click import.
-
After successfully importing the plugin, a new Tools->LovenseAndroidDeveloper menu item will be added to the Unity menu bar. Click to enter and set the developer token, then click Save to save the token.
At this point, you can quickly start developing using the iOS SDK. The LovenseDemo folder is an example, and deleting it does not affect your project.
Guide:
1. Search toys
Add listener: LovenseiOSSDK.oniOSGetToysEvent.AddListener(OnGetToysEvent);
Remove listener: LovenseiOSSDK.oniOSGetToysEvent.RemoveListener(OnGetToysEvent);
The callback function is not allowed to take parameters, and the obtained toys are all in LovenseiOSSDK.iOSToys
Search toys: LovenseiOSSDK.GetInstance().SearchToys();
2. Stop searching for toys
LovenseiOSSDK.GetInstance().StopSearch();
3. Connect Toys
Add listener: LovenseiOSSDK.oniOSConnectEvent.AddListener(onToysConnectEvent);
Remove listener: LovenseiOSSDK.oniOSConnectEvent.RemoveListener(onToysConnectEvent);
Listening callback function: public void onToysConnectEvent(string toyId, int status, string msg){}
Connect Toys: LovenseiOSSDK.GetInstance().ConnectToy(toyId);
Disconnect: LovenseiOSSDK.GetInstance().DisConnectToy(toyId);
4. Battery monitoring
Add battery monitoring:
LovenseiOSSDK.oniOSGetBatteryEvent.AddListener(onCallBackBatteryListenerFunc);
Remove power monitoring:
LovenseiOSSDK.oniOSGetBatteryEvent.RemoveListener(onCallBackBatteryListenerFunc);
Listening function: public void onCallBackBatteryListenerFunc(string toyId, int battery)
Send query:
LovenseiOSSDK.GetInstance().SendFunctionWithoutValue(LovenseCommandType.GET_BATTERY );
5. Obtain parameters such as device type
LovenseiOSSDK.GetInstance().SendFunctionWithoutValue(toyId, LovenseCommandType.GET_DEVICETYPE);
6. Send Functions
Single Function:
LovenseiOSSDK.GetInstance().SendFunction(toyId, command, timeSec, loopRunning, loopPause);
Multiple Functions: LovenseiOSSDK.GetInstance().SendFunctions(toyId, commands, timeSec, loopRunning, loopPause);
command: the type is LovenseiOSCommand
commands: the type is List
timeSec: total running time
loopRunning: Running time. Use in conjunction with loopPause to control and stop the device.
loopPause: Suspend time. Use in conjunction with the above loopRunning to control and stop the device.
7. Send Patterns
LovenseiOSSDK.GetInstance().SendPattern(toyId, typeList, valueList, timeMs, timeSec);
typeList: the type of command, the type is List
valueList: a list of intensity changes, the type is List
timeMs: how often to change the intensity, time unit: milliseconds
timeSec: total running time, time unit: seconds
8. Send Preset
LovenseiOSSDK.GetInstance().SendPreset(toyId, mode, timeSec);
There are currently four presets:
mode=0 earthquake mode
mode=1 fireworks mode
mode=2 pulse mode
mode=3 wave mode
timeSec: total running time, time unit: seconds
9. Stop Toys
LovenseiOSSDK.GetInstance().StopAll(toyId);