DeveloperDeveloper
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
  • Game Engine Plugin
  • Unity Universal Plugin For Remote
  • Unity Plugin - Android SDK
  • Unity Plugin - iOS SDK
  • Unity Plugin - Windows
  • Unity Plugin - Dongle
  • Unity Plugin - Mac
  • Unreal Plugin For Remote
  • C++ DLL - Windows
  • Ren'Py Plugin For Remote

Unity Plugin - Windows

Introduction

This Unity plugin allows Windows devices to connect Lovense toys and send control commands.

Note: A Bluetooth adapter is required to use this plugin.

Compatibility

Unity version: >= 2019.4.0

Api Compatibility Level:

  • For .Net 4.x, the import package name is windowsPlugin_.Net4.x.unitypackage.
  • For .Net Framework, the import package name is windowsPlugin_.NetFramework.unitypackage.
  • For .Net Standard 2.0, the import package name iswindowsPlugin_.NetStandard2.0.unitypackage.
  • For .Net Standard 2.1, the import package name is windowsPlugin_.NetStandard2.1.unitypackage.

Import the plugin

  1. Download the plugin package from here. The latest version of the current plugin is V1.7 click to view version records

    windowsPlugin_.Net4.x.unitypackage

    windowsPlugin_.NetFramework.unitypackage

    windowsPlugin_.NetStandard2.0.unitypackage

    windowsPlugin_.NetStandard2.1.unitypackage

  2. Import the appropriate package based on your project's Api Compatibility Level.

    image

  3. Select all options and click import.

    image

  4. The file Assets/StreamingAssets/LovenseToySupportConfig.json is the configuration file for the toy support directive, and the version field represents the version of the information. The current latest version is 1.4. If it is older than this version, it is recommended to download and replace the file.

Dowload: LovenseToySupportConfig.json

The LovenseDemo folder is an example that you can refer to. Removing it won't affect the functionality.

Guide

1. Search for attached toys.

public class YourLovenseToyUI: MonoBehaviour {
	 // do search
   private void DoSearch() {
      LovenseWinBleTools.GetInstance().ScanDevices();
   }

   //
	private void OnGetToy(string id,LovenseWinBleToy toy) {
       // Show the search result in the UI
	}

   private void OnScanEnd() {
       // on scan ended.
   }

   void Awake(){
      // Add listener
		 LovenseWinBleTools.onGetToyEvent.AddListener(OnGetToy);
        LovenseWinBleTools.onGetToyScanEnd.AddListener(OnWinbleToyScanEnd);
   }

	void OnDestory() {
		// Remove listener
		 LovenseWinBleTools.onGetToyEvent.RemoveListener(OnGetToy);
        LovenseWinBleTools.onGetToyScanEnd.RemoveListener(OnScanEnd);
	}
}

2. Connect or disConnect toys

public class YourLovenseToyUI: MonoBehaviour {
   
   //do search toys
   private void DoConnect(List<string> ids) {
        LovenseWinBleTools.GetInstance().ConnectToys(ids);
   }

   private void DoDisConnect(List<string> ids) {
        LovenseWinBleTools.GetInstance().DisconnectToys(ids);
   }

   private void onToysConnect(string toyId, bool connected)
       //Code executes when the connection state of the toy changes
   }

   private void OnConnectCompleted() {
       
   }

   private void OnDisConnectCompleted() {
    
   }

   void Awake() {
      // Add listener
      LovenseWinBleTools.onConnectChangeEvent.AddListener(onToysConnect);
      LovenseWinBleTools.onConnectToysCompletedEvent.AddListener(OnConnectCompleted);
      LovenseWinBleTools.onDisConnectToysCompletedEvent.AddListener(OnDisConnectCompleted);
   } 
 
   void OnDestroy() {
       // Remove listener
     LovenseWinBleTools.onConnectChangeEvent.RemoveListener(onToysConnect);
   }
}

3. Send commands

3.1 Get battery

public class YourLovenseToyUI : MonoBehaviour {
   
  private void DoGetBattery(string id) {
    LovenseWinBleTools.GetInstance().SendFunctionWithoutValue(id, LovenseCommandType.GETBATTERY);
  }

  private void OnGetBattery(string id, string battery){
  
  }

  void Awake() {
    // Add listener
     LovenseWinBleTools.onGetBatteryEvent.AddListener(OnGetBattery);
  } 

  void OnDestroy() {
    // Remove listener:
     LovenseWinBleTools.onGetBatteryEvent.RemoveListener(OnGetBattery);
  }
}

3.2 Send function commands

public class YourLovenseToyUI : MonoBehaviour {
   
  private void DoSendCommands(List<string> toyIds, List<LovenseCommand> commands, float timeSec, float loopRunningSec, float loopPauseSec) {
    LovenseWinBleTools.GetInstance().SendFunctions(toyIds,commands,timeSec,loopRunningSec,loopPauseSec);
  }

  private void OnSendCommandError(int code){
      //...
  }

  void Awake() {
    // Add listener
     LovenseWinBleTools.onSendCommandErrorEvent.AddListener(OnSendCommandError);
  } 

  void OnDestroy() {
     // Remove listener:
     LovenseWinBleTools.onSendCommandErrorEvent.RemoveListener(OnSendCommandError);
  }
}

3.3 Send pattern commands

public class YourLovenseToyUI : MonoBehaviour {

  private void DoSendPattern(List<string> toyIds, List<LovenseCommandType> typeList, List<int> strengthValues, float timeSec, int intervalsMs) {
     LovenseWinBleTools.GetInstance().SendPattern(toyIds, typeList, strengthValues, timeSec,timeSec,timeMs);
  }

  private void OnSendCommandError(int code){
      //callback function...
  }

  void Awake() {
    // Add listener
     LovenseWinBleTools.onSendCommandErrorEvent.AddListener(OnSendCommandError);
  } 

  void OnDestroy() {
     // Remove listener:
     LovenseWinBleTools.onSendCommandErrorEvent.RemoveListener(OnSendCommandError);
  }
}

strengthValues: Changes in intensity

intervalsMs: Time interval for intensity switching in milliseconds

timeSec: Total running time in seconds

3.4 Send preset commands

public class YourLovenseToyUI : MonoBehaviour {

   private void DoSendPreset(List<string> ids, int mode, float timeSec) {
      LovenseWinBleTools.GetInstance().SendPreset(ids, mode, timeSec);
   }

   private void OnSendCommandError(int code){
      //...
   }

   void Awake() {
    // Add listener
     LovenseWinBleTools.onSendCommandErrorEvent.AddListener(OnSendCommandError);
   } 

   void OnDestroy() {
     // Remove listener:
     LovenseWinBleTools.onSendCommandErrorEvent.RemoveListener(OnSendCommandError);
   }
}

mode:we provide four preset patterns:0 is earthquake,1 is fireworks,2 is pulse,3 is wave

3.5 Send stop command

public class YourLovenseToyUI : MonoBehaviour {

   private void DoSendStop(List<string> ids) {
       LovenseWinBleTools.GetInstance().StopAll(ids);
   }

   private void OnSendCommandError(int code){
      //...
   }

   void Awake() {
    // Add listener
     LovenseWinBleTools.onSendCommandErrorEvent.AddListener(OnSendCommandError);
   } 

   void OnDestroy() {
     // Remove listener:
     LovenseWinBleTools.onSendCommandErrorEvent.RemoveListener(OnSendCommandError);
   }
}

3.6 Add interface for Data Reporting

public class YourLovenseToyUI : MonoBehaviour {

   private void DoAddDataReporting(string toyId,bool open) {
       LovenseWinBleTools.GetInstance().SetDataReportingMode(toyId,open); //Only by using this function and setting it to true will the toy data be reported
   }


   //callback function.
   private void OnGetReportingData(string id,LovenseDataReportingEventType type,int target,int value){
      //code 
   }

   void Awake() {
        LovenseWinBleTools.GetInstance().AddDataReportingListener(toyId,OnGetReportingData);
   } 

   void OnDestroy() {
    // Remove listener:
        LovenseWinBleTools.GetInstance().RemoveDataReportingListener(toyId,OnGetReportingData);
   }
}

Interface

LovenseWinBleTools

Method

GetInstance
  • Description:

    Get the singleton instance of LovenseWinBleTools

  • Parameters: None

  • Return: LovenseWinBleTools instance

GetBattery
  • Description:

    Obtain the power of the toy,when is completed, the onGetBatteryEvent event will be triggered.

  • Parameters:

    NameTypeDefaultRequiredDescription
    toyIdstringyesThe toy ID you want to obtain battery power
  • Return: None

ScanDevices
  • Description:

    Search for nearby toys, when the search is completing, the onGetToyEvent event will be triggered,And the end of the scan will trigger onGetToyScanEnd event

  • Parameters: None

  • Return: None

SendFunctions
  • Description:

    Send Function commands to the toys.

  • Parameters:

    NameTypeDefaultRequiredDescription
    toyIdsList<string>yesThe toys ID you want to obtain power from
    commandsList<LovenseCommand>yesSee LovenseCommand
    timeSecfloatyesTotal running time in second, 0 represents no limit
    loopRunningSecfloat0notime running for each command loop in second
    loopPauseSecfloat0notime gap for each command loop in second
  • Return: None

SendPattern
  • Description:

    Send a series of functions to the toys, they will execute all the functions in types according to the order of the level in values with the interval of intervalsMs.

  • Parameters:

    NameTypeDefaultRequiredDescription
    toyIdsList<string>yesThe toys you want to control
    typesList<LovenseCommandType>yesSee LovenseCommandType
    strengthValuesList<int>yesThe order of the levels
    timeSecfloatyesThe total runtime in second, "0" = indefinite time length.
    intervalsMsint150noThe level interval in milliseconds ,Should be greater than 100 ,default 150
  • Return: None

SendPreset
  • Description:

    Send a preset command to the toys.

  • Parameters:

    NameTypeDefaultRequiredDescription
    toysList<string>yesThe toys you want to control
    modeintyesThe preset name to send, we provide four preset patterns: 0 is earthquake,1 is fireworks,2 is pulse,3 is wave
    timeSecfloatyesThe total runtime in second, "0" = indefinite time length.
  • Return: None

StopAll
  • Description:

    Send a stop command to the toys.

  • Parameters:

    NameTypeDescription
    toyIdsList<string>The toys you want to stop
  • Return: None

SetDataReportingMode
  • Description:

    Switch the toys to data reporting mode.

  • Parameters:

    NameTypeDefaultRequiredDescription
    toyIdstringyesThe toys you want to set
    openboolyesWhether the data reporting is enabled for toy
    modeint0yesWhich reporting mode for toy
    • mode for Solace Pro:
      • 0:
        • Report the thrusting speed and stroke range of Solace Pro in real-time to the app.
        • In this mode, Solace Pro can't be controlled by its own button and can only be controlled by control commands.
      • 1:
        • Report the thrusting speed and stroke range of Solace Pro in real-time to the app.
        • In this mode, Solace Pro can't be controlled by control commands and can only be controlled by its own button.
  • Return: None

CheckDataReportingEnable
  • Description:

    Check if the toy supports data reporting function. If so, onGetToyDataReportingEnabled will be triggered.

    Note: This function will be automatically executed right after the toy is connected.if toy's isSupportDataReporting is false, It is recommended that you set the callback of onGetToyDataReportingEnabled before connecting to the toy.

  • Parameters:

    NameTypeDefaultRequiredDescription
    toyIdstringyesThe toys you want to check
  • Return: None

AddDataReportingListener
  • Description:

    Add a data reporting listener.

  • Parameters:

    NameTypeDescription
    idstringThe toys you want to add data reporting listener
    eventUnityAction(string toyId,LovenseDataReportingEventType type,int target,int value)callback function
  • Return: None

RemoveDataReportingListener
  • Description:

    Remove a data reporting listener.

  • Parameters:

    NameTypeDescription
    toyIdsstringThe toys you want to add data reporting listener
    eventUnityAction(string toyId,LovenseDataReportingEventType type ,int target ,int value)callback function
  • Return: None

GetSupportCommandsByType(string type)
  • Description:

    Get support commands by type Obtain Command types supported by toys through their types

  • Parameters:

    NameTypeDescription
    typestringthe type of toy
  • Return: List<LovenseCommandType>

PatternV2SetUp(string toyId, List<[PositionPatternValue]> addPatternList)
  • Description:

    Send a series of positions to Solace Pro. The onPatternV2Event event will be triggered.

  • Parameters:

    NameTypeDescription
    toyIdstringThe toy you want to set up
    addPatternListList<[PositionPatternValue]>The series value of PatternV2
  • Return: None

PlayPatternV2(string toyId)
  • Description:

    Play the predefined pattern. The onPatternV2Event event will be triggered.

  • Parameters:

    NameTypeDescription
    toyIdstringThe toy you want to play.
  • Return: None

StopPatternV2(string toyId)
  • Description:

    Stop playing the predefined pattern. The onPatternV2Event event will be triggered.

  • Parameters:

    NameTypeDescription
    toyIdstringThe toy you want to stop.
  • Return: None

SetPosition(string toyId,int position)
  • Description:

    Controls the stroker to move to a specified position(0~100).

  • Parameters:

    NameTypeDescription
    toyIdstringThe toy you want to control.
    positionintThe position of the stroker
  • Return: None

Event

onGetToyEvent
  • Description:

    Triggered when a new toy is discovered

  • Callback Parameters:

    NameTypeDescription
    toyLovenseWinbleToythe new toy is discovered
onGetToyScanEnd
  • Description:

    Triggered after scanning is completed

  • Callback Parameters:

    None

onGetBatteryEvent
  • Description:

    Triggered when getting toy's battery is complete.

  • Callback Parameters:

    NameTypeDescription
    toyIdstringThe toy's ID
    batterystringThe toy's battery life. Will have a s prefix when the toy is in a status that the return value is not reliable. e.g. When the toy is viberating and toy's battery life is 90, the return value will be s90
onConnectChangeEvent
  • Description:

    Triggered when connected toy's connection status is changed.

  • Callback Parameters:

    NameTypeDescription
    toyIdstringThe toy's ID
    connectedboolConnection status
onSendCommandErrorEvent
  • Description:

    Triggered when an error occurs during connection or control

  • Callback Parameters:

    NameTypeDescription
    codeintID where the error occurred
  • code:

    ValueDescription
    404The toy is not connected
onConnectToysCompletedEvent
  • Description:

    Triggered when all toys that need to be connected in order to completed the connection

  • Callback Parameters:

    None

onDisConnectToysCompletedEvent
  • Description:

    Triggered when all toys that need to be disconnected in order to complete the disconnection

  • Callback Parameters:

    None

onGetToyDataReportingEnabled
  • Description:

    Triggered after send [CheckDataReportingEnable]

  • Callback Parameters:

    NameTypeDescription
    idstringthe toy's ID
onPatternV2Event
  • Description:

    Triggered when executing PatternV2.

  • Callback Parameters:

    NameTypeDescription
    typePatternV2ActionTypeWhat kind of PatternV2 Action
    idstringThe toy's ID
    codeintThe response code of this action
  • code(if type is PatternV2ActionType.SETUP):

    ValueDescription
    0The PatternV2 status is stoped
    1The PatternV2 status is paused
    2The PatternV2 status is stoped
    3The PatternV2 status is playing, but the series value of PatternV2 is empty

LovenseWinbleToy

  • Description:

    The information of the Lovense toy

  • Properties:

    NameTypeDescription
    idstringThe toy's id
    namestringThe toy's name, such as "nora"
    addressstringThe toy's MAC address
    isConnectedintThe toy's connection status
    typeNamestringThe toy's typeName
    batterystringThe toy's battery level, from 0 to 100 ,SendFunctionWithoutValue(id,LovenseCommandType.GETBATTERY) needs to be called to update
    isSupportDataReportingboolDetermine if the toy currently support data reporting. Need the toy to be connected in order to synchronize.

LovenseCommand

  • Description:

    The toy control command

  • Properties:

    NameTypeDescription
    typeLovenseCommandTypeSee below
    valueintFunction level

Function Level:

TypeRange
VIBRATE0 - 20
VIBRATE10 - 20
VIBRATE20 - 20
VIBRATE30 - 20
ROTATE0 - 20
PUMP0 - 3
THRUSTING0 - 20
FINGERING0 - 20
SUCTION0 - 20
DEPTH0 - 3
OSCILLATE0 - 20
GETBATTERY

LovenseCommandType

  • Description:

    The enum of the toy function type.

  • Enum:

    Value
    VIBRATE
    VIBRATE1
    VIBRATE2
    VIBRATE3
    ROTATE
    PUMP
    THRUSTING
    FINGERING
    SUCTION
    DEPTH
    GETBATTERY
    POSITION
    OSCILLATE

The DEPTH command is a setting command that requires the THRUSTRING command to take effect.

LovenseDataReportingEventType

  • Description:

    The enum of the toy data reporting event type.

  • Enum:

    ValueDescription
    KEY_DOWNTrigger when a key is pressed
    KEY_UPTrigger when a key is up
    VIBTATETrigger when the toy vibrates
    ROTATETrigger when the toy rotate
    SHAKETrigger when the toy shake
    MOVEMENTTrigger when the toy movement
    DEEPTrigger when the toy vibrates
    AIR_INTrigger when the toy is inflated
    AIR_OUTTrigger when the toy deflates
    AIR_CLOSETrigger when inflating or deflating is turned off
    AIR_OPENTrigger when inflating or deflating is turned on
    BATTERYTrigger when the battery level changes
    SHAKE_TIMESTrigger when user shakes the toy every time
    STROKE_SPEED_POSITIONTrigger when user press the button of Solace Pro

LovenseSolaceProCommand

  • Description:

    Extends from LovenseCommand, specially designed for use with SolacePro.

  • Properties:

    NameTypeDescription
    typeLovenseCommandTypeis LovenseCommandType.POSITION
    valueintSendfunctions sends a POSITION command using this value in the 1-100 range if there is no VIRATE/THRUSTING command
    strokeLowintThe stroke Value at the low end
    strokeHighintThe stroke Value at the heigh end, strokeHigh - strokeLow must be greater than 20

PositionPatternValue

  • Description:

    The position command.

  • Properties:

    NameTypeDescription
    timeintThe time in milliseconds
    positionintThe position of the stroker(0-100)

PatternV2ActionType

  • Description:

    The enum of the PatternV2 action type.

  • Enum:

    Value
    SETUP
    PLAY_OR_STOP

Version Records

[Version1.8] - 2025-01-21

  • 1.Add Oscillate command for Gush2.

  • 2.Update the configuration file to version1.5.

[Version1.7] - 2024-11-22

  • 1.Update the sending frequency and user interface.

[Version1.6] - 2024-10-28

  • 1.Fix the abnormal disconnection of the toy.

  • 2.Add event API to Solace Pro.

[Version1.5] - 2024-08-23

  • 1.Support SolacePro,Update

  • 2.Update the configuration file to version1.4.

  • 3.Modify UI structure.

[Version1.4] - 2023-11-15

    1. Command sending optimization.
    1. Add depth command.
    1. Update the configuration file to version1.3.

[Version1.3] - 2023-10-20

    1. Add Vibrate3 command.

[Version1.2] - 2023-09-28

    1. Add shake event.

[Version1.1] - 2023-09-21

    1. Data Reporting interface add parameters 'toyId'

[Version1.0] - 2023-09-12

    1. Functions
    1. Pattern
    1. Preset
    1. Connect/DisConnect
    1. Type/Battery
    1. Data Reporting Interface
Last Updated:
Explore our Forum or Support to get more inspiration or solve your problems.
Discord Channel
It is an online real-time channel where you can communicate directly with our official administrators or many excellent developers.
Forum
It is a place for Lovense developers to communicate, where you can find solutions to problems or get inspired for your projects.
Support
Find documents and tutorials that may be helpful to you.