Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Editor folder and Add asmdef #6

Open
wants to merge 13 commits into
base: unity-package
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ crashlytics-build.properties

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
/[Aa]ssets/[Ss]treamingAssets/aa/*

#Windows Plugin builds
bleplugin_projects/Windows/x64
bleplugin_projects/Windows/BlePluginWin/x64
32 changes: 32 additions & 0 deletions Assets/Plugins/Ble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#define UNITY_OSX
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
#define UNITY_WIN
#endif

using UnityEngine;
using System;
using System.Runtime.InteropServices;
Expand All @@ -31,6 +35,8 @@ public static void Initialize(Action initializedAction, Action<string> errorActi
toio.Android.BleAndroid.Initialize(initializedAction, errorAction);
#elif UNITY_OSX
toio.BlemacOS.Initialize(initializedAction, errorAction);
#elif UNITY_WIN
toio.Windows.BleWin.Initialize(initializedAction, errorAction);
#endif
}

Expand All @@ -42,6 +48,8 @@ public static void Finalize(Action finalizedAction = null)
toio.Android.BleAndroid.Finalize(finalizedAction);
#elif UNITY_OSX
toio.BlemacOS.Finalize(finalizedAction);
#elif UNITY_WIN
toio.Windows.BleWin.Finalize(finalizedAction);
#endif
}

Expand All @@ -53,6 +61,8 @@ public static void EnableBluetooth(bool enable)
toio.Android.BleAndroid.EnableBluetooth(enable);
#elif UNITY_OSX
toio.BlemacOS.EnableBluetooth(enable);
#elif UNITY_WIN
toio.Windows.BleWin.EnableBluetooth(enable);
#endif
}

Expand All @@ -64,6 +74,8 @@ public static void StartScan(string[] serviceUUIDs, Action<string, string, int,
toio.Android.BleAndroid.StartScan(serviceUUIDs, discoveredAction);
#elif UNITY_OSX
toio.BlemacOS.StartScan(serviceUUIDs, discoveredAction);
#elif UNITY_WIN
toio.Windows.BleWin.StartScan(serviceUUIDs, discoveredAction);
#endif
}

Expand All @@ -75,6 +87,8 @@ public static void StopScan()
toio.Android.BleAndroid.StopScan();
#elif UNITY_OSX
toio.BlemacOS.StopScan();
#elif UNITY_WIN
toio.Windows.BleWin.StopScan();
#endif
}

Expand All @@ -89,6 +103,9 @@ public static void ConnectToPeripheral(string identifier, Action<string> connect
#elif UNITY_OSX
toio.BlemacOS.ConnectToPeripheral(identifier, connectedPeripheralAction, discoveredServiceAction,
discoveredCharacteristicAction, disconnectedPeripheralAction);
#elif UNITY_WIN
toio.Windows.BleWin.ConnectToPeripheral(identifier, connectedPeripheralAction, discoveredServiceAction,
discoveredCharacteristicAction, disconnectedPeripheralAction);
#endif
}

Expand All @@ -100,6 +117,8 @@ public static void DisconnectPeripheral(string identifier, Action<string> discon
toio.Android.BleAndroid.DisconnectPeripheral(identifier, disconnectedPeripheralAction);
#elif UNITY_OSX
toio.BlemacOS.DisconnectPeripheral(identifier, disconnectedPeripheralAction);
#elif UNITY_WIN
toio.Windows.BleWin.DisconnectPeripheral(identifier, disconnectedPeripheralAction);
#endif
}

Expand All @@ -111,6 +130,8 @@ public static void DisconnectAllPeripherals()
toio.Android.BleAndroid.DisconnectAllPeripherals();
#elif UNITY_OSX
toio.BlemacOS.DisconnectAllPeripherals();
#elif UNITY_WIN
toio.Windows.BleWin.DisconnectAllPeripherals();
#endif
}

Expand All @@ -124,6 +145,9 @@ public static void ReadCharacteristic(string identifier, string serviceUUID, str
#elif UNITY_OSX
toio.BlemacOS.ReadCharacteristic(identifier, serviceUUID,
characteristicUUID, didReadChracteristicAction);
#elif UNITY_WIN
toio.Windows.BleWin.ReadCharacteristic(identifier, serviceUUID,
characteristicUUID, didReadChracteristicAction);
#endif
}

Expand All @@ -137,6 +161,9 @@ public static void WriteCharacteristic(string identifier, string serviceUUID, st
#elif UNITY_OSX
toio.BlemacOS.WriteCharacteristic(identifier, serviceUUID, characteristicUUID,
data, length, withResponse, didWriteCharacteristicAction);
#elif UNITY_WIN
toio.Windows.BleWin.WriteCharacteristic(identifier, serviceUUID, characteristicUUID,
data, length, withResponse, didWriteCharacteristicAction);
#endif
}

Expand All @@ -150,6 +177,9 @@ public static void SubscribeCharacteristic(string identifier, string serviceUUID
#elif UNITY_OSX
toio.BlemacOS.SubscribeCharacteristic(identifier, serviceUUID,
characteristicUUID, notifiedCharacteristicAction);
#elif UNITY_WIN
toio.Windows.BleWin.SubscribeCharacteristic(identifier, serviceUUID,
characteristicUUID, notifiedCharacteristicAction);
#endif
}

Expand All @@ -161,6 +191,8 @@ public static void UnSubscribeCharacteristic(string identifier, string serviceUU
toio.Android.BleAndroid.UnSubscribeCharacteristic(identifier, serviceUUID, characteristicUUID, action);
#elif UNITY_OSX
toio.BlemacOS.UnSubscribeCharacteristic(identifier, serviceUUID, characteristicUUID, action);
#elif UNITY_WIN
toio.Windows.BleWin.UnSubscribeCharacteristic(identifier, serviceUUID, characteristicUUID, action);
#endif
}
}
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions Assets/Plugins/ble-plugin-unity.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "ble-plugin-unity"
}
7 changes: 7 additions & 0 deletions Assets/Plugins/ble-plugin-unity.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Plugins/x86_64.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Assets/Plugins/x86_64/BehaviourProxy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace toio.Windows
{
internal class BehaviourProxy : MonoBehaviour
{
private System.Action onUpdate;
private IEnumerator initalizeExecution;

public static BehaviourProxy Create(IEnumerator initExec,System.Action updateFunc)
{
var gmo = new GameObject("BehaviourProxy");
gmo.hideFlags = HideFlags.HideAndDontSave;
Object.DontDestroyOnLoad(gmo);
var proxy = gmo.AddComponent<BehaviourProxy>();
proxy.initalizeExecution = initExec;
proxy.onUpdate = updateFunc;
return proxy;
}
void Update()
{
if(initalizeExecution != null)
{
if(!initalizeExecution.MoveNext())
{
initalizeExecution = null;
}
return;
}
if(onUpdate != null) {
onUpdate();
}
}
}
}

#endif
11 changes: 11 additions & 0 deletions Assets/Plugins/x86_64/BehaviourProxy.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/x86_64/BlePluginWinows.dll
Binary file not shown.
63 changes: 63 additions & 0 deletions Assets/Plugins/x86_64/BlePluginWinows.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading