# Unity Lovense Plugin - Using Lovense Remote

**URL:** <https://forum.developer.lovense.com/t/unity-lovense-plugin-using-lovense-remote/74>\
**Category:** Unity\
**Created:** [July 20, 2023, 3:57am UTC](https://forum.developer.lovense.com/t/unity-lovense-plugin-using-lovense-remote/74 "2023-07-20T03:57:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trebor](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@Trebor](https://forum.developer.lovense.com/u/Trebor)\
**Post date:** [July 20, 2023, 3:57am UTC](https://forum.developer.lovense.com/t/unity-lovense-plugin-using-lovense-remote/74/1 "2023-07-20T03:57:55Z")

</div>

**Description:**

This Unity plugin can search for the Lovense Remote App on the local LAN and communicate with it to send toy control commands.

Note: The Remote App needs to have Game Mode enabled.

**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:**

1. Import the appropriate package based on your project’s Api Compatibility Level\*.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/lovense2/original/1X/472f1aed90a075ffaf9ef4306c7ad9c94a249a53.jpeg)

1. Select all options and click import.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/lovense2/original/1X/62248277ffc602694eccc0ab8eac654052fc87a6.png)

**With these steps, you can quickly develop interaction between Unity and the Remote App. The LovenseDemo folder is an example that you can refer to. Removing it won’t affect the functionality.**

**Guide:**

**1. Search for the local LAN Remote and toy data.**

> Method: LovenseRemote.GetInstance().SearchAppAndToy();

> Add listener: LovenseRemote.onSearchLocalAppEvent.AddListener(OnSearchLocalApp);

> Remove listener: LovenseRemote.onSearchLocalAppEvent.RemoveListener(OnSearchLocalApp);

```auto
private void OnSearchLocalApp(SearchResult searchResult) {

// ...

}

```

**Types:**

- SearchResult

- SearchAppData

- RemoteLovenseToy

**2. List toys based on the specified IP and port:**

> Method: LovenseRemote.GetInstance().GetToys(ip, port, useHttp);

> Add listener: LovenseRemote.onGotToysEvent.AddListener(OnGetToys);

> Remove listener: LovenseRemote.onGotToysEvent.RemoveListener(OnGetToys);

```auto
private void OnGetToys(AllLovenseToysResult result) {

// ...

}

```

**Classes:**

- class AllLovenseToysResult

- class AllLovenseToys

- class LovenseToy

**3. Send commands**

Methods:

- Single command:

> LovenseRemote.GetInstance().SendFunction(string domain, int httpsPort, string toyId, LovenseCommand command, int timeSec, int stopPrevious = 1, int runningTime = 0, int pauseTime = 0, bool useHttp = false);

- Multiple commands:

> LovenseRemote.GetInstance().SendFunctions(string domain, int httpsPort, string toyId, List commands, int timeSec, int stopPrevious = 1, int runningTime = 0, int pauseTime = 0, bool useHttp = false);

> class LovenseCommand
> 
> class LovenseCommandType
> 
> timeSec: Total running time
> 
> stopPrevious: Whether to stop previous commands
> 
> runningTime: Running time, used in conjunction with pauseTime to control device operation and stoppage.
> 
> pauseTime: Pause time, used in conjunction with runningTime to control device operation and stoppage.

**4. Send Pattern**

> LovenseRemote.GetInstance().SendPattern(string domain, int httpsPort, string toyId, List types, int values, int personTimeMs, int timeSec, bool useHttp = false);

> values: Changes in intensity
> 
> personTimeMs: Time interval for intensity switching in milliseconds
> 
> timeSec: Total running time in seconds

**5. Send preset:**

> LovenseRemote.GetInstance().SendPreset(string domain, int httpsPort, string toyId, string presetName, int timeSec, bool useHttp = false);

Currently available preset names:

> “earthquake,” “fireworks,” “pulse,” “wave”

**6. SendStopCommand**

> LovenseRemote.GetInstance().SendStopFunction(string domain, int httpsPort, string toyId, bool useHttp = false);

**All toy control functions mentioned above use the HTTPS protocol by default. If you need to use the HTTP protocol, set useHttp = true and make sure it corresponds to the port number in the preceding parameters.**

---

<div class="post-metadata">

**Author:** ![Trebor](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@Trebor](https://forum.developer.lovense.com/u/Trebor)\
**Post date:** [July 20, 2023, 3:58am UTC](https://forum.developer.lovense.com/t/unity-lovense-plugin-using-lovense-remote/74/2 "2023-07-20T03:58:13Z")

</div>

# **Download the plugin here:**
  
[https://developer.lovense.com/unity-remote/remotePlugin\_.Net4.x.unitypackage](https://developer.lovense.com/unity-remote/remotePlugin_.Net4.x.unitypackage)  
[https://developer.lovense.com/unity-remote/remotePlugin\_.NetFramework.unitypackage](https://developer.lovense.com/unity-remote/remotePlugin_.NetFramework.unitypackage)  
[https://developer.lovense.com/unity-remote/remotePlugin\_.NetStandard2.0.unitypackage](https://developer.lovense.com/unity-remote/remotePlugin_.NetStandard2.0.unitypackage)  
[https://developer.lovense.com/unity-remote/remotePlugin\_.NetStandard2.1.unitypackage](https://developer.lovense.com/unity-remote/remotePlugin_.NetStandard2.1.unitypackage)

---

<div class="post-metadata">

**Author:** ![Patrickjqc](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Patrickjqc](https://forum.developer.lovense.com/u/Patrickjqc)\
**Post date:** [August 30, 2023, 5:17pm UTC](https://forum.developer.lovense.com/t/unity-lovense-plugin-using-lovense-remote/74/3 "2023-08-30T17:17:34Z")

</div>

Hi,  
In the method DoSearch  
the example shows:  
`LovenseRemote.GetInstance().SearchAppAndToy();`  
but SearchAppAndToy doesnt exists in LovenseRemote class. I have imported the latest pkg remotePlugin\_.Net4.x\_V1.1\_.unitypackage in Unity.

Am I missing something?  
Thanks.
