当前提交
eb60b20a
共有 38 个文件被更改,包括 1201 次插入 和 0 次删除
-
8Assets/Scripts/Multipeer.meta
-
100Assets/Scripts/Multipeer/MCSession.cs
-
11Assets/Scripts/Multipeer/MCSession.cs.meta
-
18Assets/Scripts/Multipeer/MCSessionSendDataMode.cs
-
11Assets/Scripts/Multipeer/MCSessionSendDataMode.cs.meta
-
62Assets/Scripts/Multipeer/NSData.cs
-
11Assets/Scripts/Multipeer/NSData.cs.meta
-
56Assets/Scripts/Multipeer/NSError.cs
-
11Assets/Scripts/Multipeer/NSError.cs.meta
-
18Assets/Scripts/Multipeer/NSErrorException.cs
-
11Assets/Scripts/Multipeer/NSErrorException.cs.meta
-
53Assets/Scripts/Multipeer/NSMutableData.cs
-
11Assets/Scripts/Multipeer/NSMutableData.cs.meta
-
15Assets/Scripts/Multipeer/NSMutableDataExtensions.cs
-
11Assets/Scripts/Multipeer/NSMutableDataExtensions.cs.meta
-
79Assets/Scripts/Multipeer/NSString.cs
-
11Assets/Scripts/Multipeer/NSString.cs.meta
-
17Assets/Scripts/Multipeer/NativeApi.cs
-
11Assets/Scripts/Multipeer/NativeApi.cs.meta
-
8Assets/Scripts/Multipeer/NativeCode.meta
-
62Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate-C-Bridge.m
-
37Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate-C-Bridge.m.meta
-
13Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate.h
-
27Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate.h.meta
-
132Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate.m
-
105Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate.m.meta
-
30Assets/Scripts/Multipeer/NativeCode/NSData-C-Bridge.m
-
37Assets/Scripts/Multipeer/NativeCode/NSData-C-Bridge.m.meta
-
12Assets/Scripts/Multipeer/NativeCode/NSError-C-Bridge.m
-
37Assets/Scripts/Multipeer/NativeCode/NSError-C-Bridge.m.meta
-
22Assets/Scripts/Multipeer/NativeCode/NSMutableData-C-Bridge.m
-
37Assets/Scripts/Multipeer/NativeCode/NSMutableData-C-Bridge.m.meta
-
52Assets/Scripts/Multipeer/NativeCode/NSString-C-Bridge.m
-
37Assets/Scripts/Multipeer/NativeCode/NSString-C-Bridge.m.meta
-
17Assets/Scripts/Multipeer/SerializedARCollaborationDataExtensions.cs
-
11Assets/Scripts/Multipeer/SerializedARCollaborationDataExtensions.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: ab5ca8171efd6403fa3e0f422eccde1e |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct MCSession : IDisposable, IEquatable<MCSession> |
|||
{ |
|||
IntPtr m_Ptr; |
|||
|
|||
public bool Created => m_Ptr != IntPtr.Zero; |
|||
|
|||
public bool Enabled |
|||
{ |
|||
get |
|||
{ |
|||
if (!Created) |
|||
return false; |
|||
return GetEnabled(this); |
|||
} |
|||
|
|||
set |
|||
{ |
|||
if (!Created && value) |
|||
throw new InvalidOperationException(); |
|||
SetEnabled(this, value); |
|||
} |
|||
} |
|||
|
|||
public MCSession(string peerName, string serviceType) |
|||
{ |
|||
if (peerName == null) |
|||
throw new ArgumentNullException(nameof(peerName)); |
|||
|
|||
if (serviceType == null) |
|||
throw new ArgumentNullException(nameof(serviceType)); |
|||
|
|||
using (var peerName_NSString = new NSString(peerName)) |
|||
using (var serviceType_NSString = new NSString(serviceType)) |
|||
{ |
|||
m_Ptr = InitWithName(peerName_NSString, serviceType_NSString); |
|||
} |
|||
} |
|||
|
|||
public void SendToAllPeers(NSData data, MCSessionSendDataMode mode) |
|||
{ |
|||
if (!Created) |
|||
throw new InvalidOperationException($"The {typeof(MCSession).Name} has not been created."); |
|||
|
|||
if (!data.Created) |
|||
throw new ArgumentException($"'{nameof(data)}' is not valid.", nameof(data)); |
|||
|
|||
using (var error = SendToAllPeers(this, data, mode)) |
|||
{ |
|||
if (error.Valid) |
|||
throw error.ToException(); |
|||
} |
|||
} |
|||
|
|||
public int ReceivedDataQueueSize => GetReceivedDataQueueSize(this); |
|||
|
|||
public NSData DequeueReceivedData() |
|||
{ |
|||
if (!Created) |
|||
throw new InvalidOperationException($"The {typeof(MCSession).Name} has not been created."); |
|||
|
|||
return DequeueReceivedData(this); |
|||
} |
|||
|
|||
public int ConnectedPeerCount => GetConnectedPeerCount(this); |
|||
|
|||
public void Dispose() => NativeApi.CFRelease(ref m_Ptr); |
|||
public override int GetHashCode() => m_Ptr.GetHashCode(); |
|||
public override bool Equals(object obj) => (obj is MCSession) && Equals((MCSession)obj); |
|||
public bool Equals(MCSession other) => m_Ptr == other.m_Ptr; |
|||
public static bool operator==(MCSession lhs, MCSession rhs) => lhs.Equals(rhs); |
|||
public static bool operator!=(MCSession lhs, MCSession rhs) => !lhs.Equals(rhs); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_sendToAllPeers")] |
|||
static extern NSError SendToAllPeers(MCSession self, NSData data, MCSessionSendDataMode mode); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_initWithName")] |
|||
static extern IntPtr InitWithName(NSString name, NSString serviceType); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_ReceivedDataQueueSize")] |
|||
static extern int GetReceivedDataQueueSize(MCSession self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_DequeueReceivedData")] |
|||
static extern NSData DequeueReceivedData(MCSession self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_ConnectedPeerCount")] |
|||
static extern int GetConnectedPeerCount(MCSession self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_SetEnabled")] |
|||
static extern void SetEnabled(MCSession self, bool enabled); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_GetEnabled")] |
|||
static extern bool GetEnabled(MCSession self); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f0dd3cf9695cb42f7b9ffa20d3a59011 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
/// <summary>
|
|||
/// MCSession send modes
|
|||
/// </summary>
|
|||
public enum MCSessionSendDataMode |
|||
{ |
|||
/// <summary>
|
|||
/// Guaranteed reliable and in-order delivery.
|
|||
/// </summary>
|
|||
Reliable, |
|||
|
|||
/// <summary>
|
|||
/// Sent immediately without queuing, no guaranteed delivery.
|
|||
/// </summary>
|
|||
Unreliable |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5673d45a5dae34743841658416feef52 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using Unity.Collections; |
|||
using Unity.Collections.LowLevel.Unsafe; |
|||
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct NSData : IDisposable, IEquatable<NSData> |
|||
{ |
|||
IntPtr m_Ptr; |
|||
|
|||
internal NSData(IntPtr existing) => m_Ptr = existing; |
|||
|
|||
public bool Created => m_Ptr != IntPtr.Zero; |
|||
|
|||
public int Length => Created ? GetLength(this) : 0; |
|||
|
|||
public unsafe NSData(NativeSlice<byte> bytes, bool copy) |
|||
{ |
|||
if (copy) |
|||
{ |
|||
m_Ptr = CreateWithBytes(bytes.GetUnsafePtr(), bytes.Length); |
|||
} |
|||
else |
|||
{ |
|||
m_Ptr = CreateWithBytesNoCopy(bytes.GetUnsafePtr(), bytes.Length, false); |
|||
} |
|||
} |
|||
|
|||
public unsafe NativeSlice<byte> Bytes |
|||
{ |
|||
get |
|||
{ |
|||
if (!Created) |
|||
throw new InvalidOperationException($"The {typeof(NSData).Name} has not been created."); |
|||
|
|||
return NativeSliceUnsafeUtility.ConvertExistingDataToNativeSlice<byte>(GetBytes(this), 1, GetLength(this)); |
|||
} |
|||
} |
|||
|
|||
public void Dispose() => NativeApi.CFRelease(ref m_Ptr); |
|||
|
|||
public override int GetHashCode() => m_Ptr.GetHashCode(); |
|||
public override bool Equals(object obj) => (obj is NSData) && Equals((NSData)obj); |
|||
public bool Equals(NSData other) => m_Ptr == other.m_Ptr; |
|||
public static bool operator==(NSData lhs, NSData rhs) => lhs.Equals(rhs); |
|||
public static bool operator!=(NSData lhs, NSData rhs) => !lhs.Equals(rhs); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSData_getLength")] |
|||
static extern int GetLength(NSData self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSData_getBytes")] |
|||
static extern unsafe void* GetBytes(NSData self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSData_createWithBytes")] |
|||
static extern unsafe IntPtr CreateWithBytes(void* bytes, int length); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSData_createWithBytesNoCopy")] |
|||
static extern unsafe IntPtr CreateWithBytesNoCopy(void* bytes, int length, bool freeWhenDone); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0aac506fdc0254d79b2479e6735d7ba3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct NSError : IDisposable, IEquatable<NSError> |
|||
{ |
|||
IntPtr m_Ptr; |
|||
|
|||
public bool Valid => m_Ptr != IntPtr.Zero; |
|||
|
|||
public NSErrorException ToException() |
|||
{ |
|||
return new NSErrorException(Code, Description); |
|||
} |
|||
|
|||
public long Code |
|||
{ |
|||
get |
|||
{ |
|||
if (!Valid) |
|||
throw new InvalidOperationException($"The {typeof(NSError).Name} is not valid."); |
|||
|
|||
return GetCode(this); |
|||
} |
|||
} |
|||
|
|||
public string Description |
|||
{ |
|||
get |
|||
{ |
|||
if (!Valid) |
|||
throw new InvalidOperationException($"The {typeof(NSError).Name} is not valid."); |
|||
|
|||
using (var description = GetLocalizedDescription(this)) |
|||
{ |
|||
return description.ToString(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void Dispose() => NativeApi.CFRelease(ref m_Ptr); |
|||
public override int GetHashCode() => m_Ptr.GetHashCode(); |
|||
public override bool Equals(object obj) => (obj is NSError) && Equals((NSError)obj); |
|||
public bool Equals(NSError other) => m_Ptr == other.m_Ptr; |
|||
public static bool operator==(NSError lhs, NSError rhs) => lhs.Equals(rhs); |
|||
public static bool operator!=(NSError lhs, NSError rhs) => !lhs.Equals(rhs); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSError_code")] |
|||
static extern long GetCode(NSError error); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSError_localizedDescription")] |
|||
static extern NSString GetLocalizedDescription(NSError error); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 10a04c15626774337abc28e3ed0dc046 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
public class NSErrorException : Exception |
|||
{ |
|||
public NSErrorException(long code, string description) |
|||
: base($"NSError {code}: {description}") |
|||
{ |
|||
Code = code; |
|||
Description = description; |
|||
} |
|||
|
|||
public long Code { get; private set; } |
|||
|
|||
public string Description { get; private set; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 491dc7d106d7642499e0ccfe7d11bf70 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct NSMutableData : IDisposable, IEquatable<NSMutableData> |
|||
{ |
|||
IntPtr m_Ptr; |
|||
|
|||
internal NSMutableData(IntPtr existing) => m_Ptr = existing; |
|||
|
|||
public bool Created => m_Ptr != IntPtr.Zero; |
|||
|
|||
public NSData ToNSData() => new NSData(m_Ptr); |
|||
|
|||
// public void Append(IntPtr bytes, int length)
|
|||
// {
|
|||
// if (!Created)
|
|||
// throw new InvalidOperationException($"Cannot append to the {typeof(NSMutableData).Name} because it has not been created.");
|
|||
|
|||
// Append(m_Ptr, bytes, length);
|
|||
// }
|
|||
|
|||
// public static NSMutableData CreateEmpty() => new NSMutableData(Init());
|
|||
|
|||
// public static NSMutableData CreateWithBytes(IntPtr bytes, int length)
|
|||
// => new NSMutableData(InitWithBytes(bytes, length));
|
|||
|
|||
// public static NSMutableData CreateWithBytesNoCopy(IntPtr bytes, int length, bool freeBytesOnDisposal = false)
|
|||
// => new NSMutableData(InitWithBytesNoCopy(bytes, length, freeBytesOnDisposal));
|
|||
|
|||
public void Dispose() => NativeApi.CFRelease(ref m_Ptr); |
|||
|
|||
public override int GetHashCode() => m_Ptr.GetHashCode(); |
|||
public override bool Equals(object obj) => (obj is NSMutableData) && Equals((NSMutableData)obj); |
|||
public bool Equals(NSMutableData other) => m_Ptr == other.m_Ptr; |
|||
public static bool operator==(NSMutableData lhs, NSMutableData rhs) => lhs.Equals(rhs); |
|||
public static bool operator!=(NSMutableData lhs, NSMutableData rhs) => !lhs.Equals(rhs); |
|||
|
|||
// [DllImport("__Internal", EntryPoint="UnityMultipeer_NSMutableData_init")]
|
|||
// static extern IntPtr Init();
|
|||
|
|||
// [DllImport("__Internal", EntryPoint="UnityMultipeer_NSMutableData_initWithBytes")]
|
|||
// static extern IntPtr InitWithBytes(IntPtr bytes, int length);
|
|||
|
|||
// [DllImport("__Internal", EntryPoint="UnityARKit_NSMutableData_initWithBytesNoCopy")]
|
|||
// static extern IntPtr InitWithBytesNoCopy(IntPtr bytes, int length, bool freeBytesOnDisposal);
|
|||
|
|||
// [DllImport("__Internal", EntryPoint="UnityARKit_NSMutableData_append")]
|
|||
// static extern IntPtr Append(IntPtr ptr, IntPtr bytes, int length);
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 57f6bd29a74244f9590efc743e8ee5df |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace Unity.iOS.Multipeer.Unsafe |
|||
{ |
|||
public static unsafe class NSMutableDataUnsafeUtility |
|||
{ |
|||
// public static NSMutableData CreateWithBytes(byte[] bytes, int offset, int length)
|
|||
// {
|
|||
// fixed(byte* ptr = &bytes[offset])
|
|||
// {
|
|||
// return NSMutableData.CreateWithBytes(new IntPtr(ptr), length);
|
|||
// }
|
|||
// }
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 169ce82dbd54c49d4ae6fb74311fa48c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using Unity.Collections; |
|||
using Unity.Collections.LowLevel.Unsafe; |
|||
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
public struct NSString : IDisposable, IEquatable<NSString> |
|||
{ |
|||
IntPtr m_Ptr; |
|||
|
|||
internal NSString(IntPtr existing) => m_Ptr = existing; |
|||
|
|||
public NSString(string text) => m_Ptr = CreateWithString(text, text.Length); |
|||
|
|||
public NSString(NSData serializedString) |
|||
{ |
|||
if (!serializedString.Created) |
|||
throw new ArgumentException("The serialized string is not valid.", nameof(serializedString)); |
|||
|
|||
m_Ptr = Deserialize(serializedString); |
|||
} |
|||
|
|||
public bool Created => m_Ptr != IntPtr.Zero; |
|||
|
|||
public int Length => GetLength(this); |
|||
|
|||
public override unsafe string ToString() |
|||
{ |
|||
if (!Created) |
|||
return string.Empty; |
|||
|
|||
using (var buffer = new NativeArray<byte>(GetLengthOfBytes(this), Allocator.TempJob, NativeArrayOptions.UninitializedMemory)) |
|||
{ |
|||
if (GetBytes(this, buffer.GetUnsafePtr(), buffer.Length)) |
|||
{ |
|||
return Marshal.PtrToStringUni(new IntPtr(buffer.GetUnsafePtr()), Length); |
|||
} |
|||
else |
|||
{ |
|||
return string.Empty; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public NSData Serialize() |
|||
{ |
|||
if (!Created) |
|||
throw new InvalidOperationException($"The {typeof(NSString).Name} has not been created."); |
|||
|
|||
return Serialize(this); |
|||
} |
|||
|
|||
public void Dispose() => NativeApi.CFRelease(ref m_Ptr); |
|||
public override int GetHashCode() => m_Ptr.GetHashCode(); |
|||
public override bool Equals(object obj) => (obj is NSString) && Equals((NSString)obj); |
|||
public bool Equals(NSString other) => m_Ptr == other.m_Ptr; |
|||
public static bool operator==(NSString lhs, NSString rhs) => lhs.Equals(rhs); |
|||
public static bool operator!=(NSString lhs, NSString rhs) => !lhs.Equals(rhs); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_createWithString")] |
|||
static extern IntPtr CreateWithString([MarshalAs(UnmanagedType.LPWStr)] string text, int length); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_lengthOfBytesUsingEncoding")] |
|||
static extern int GetLengthOfBytes(NSString self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_getLength")] |
|||
static extern int GetLength(NSString self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_getBytes")] |
|||
static extern unsafe bool GetBytes(NSString self, void* buffer, int length); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSString_serialize")] |
|||
static extern NSData Serialize(NSString self); |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMC_NSString_deserialize")] |
|||
static extern IntPtr Deserialize(NSData data); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2a2bbe15074f94af4b35f25e435174f6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace Unity.iOS.Multipeer |
|||
{ |
|||
internal static class NativeApi |
|||
{ |
|||
public static void CFRelease(ref IntPtr ptr) |
|||
{ |
|||
CFRelease(ptr); |
|||
ptr = IntPtr.Zero; |
|||
} |
|||
|
|||
[DllImport("__Internal", EntryPoint="UnityMultipeer_CFRelease")] |
|||
public static extern void CFRelease(IntPtr ptr); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 06e6b03cb95994416a492630b1c74fd0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 841a08ffbdce6452182dcbfc65a3054c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#include "MultipeerDelegate.h" |
|||
|
|||
typedef void* ManagedMultipeerDelegate; |
|||
typedef void* ManagedNSError; |
|||
|
|||
ManagedMultipeerDelegate UnityMC_Delegate_initWithName(void* name_nsstring, void* serviceType_nsstring) |
|||
{ |
|||
NSString* name = (__bridge NSString*)name_nsstring; |
|||
MultipeerDelegate* delegate = [[MultipeerDelegate alloc] initWithName:name |
|||
serviceType:(__bridge NSString*)serviceType_nsstring]; |
|||
return (__bridge_retained void*)delegate; |
|||
} |
|||
|
|||
ManagedNSError UnityMC_Delegate_sendToAllPeers(void* self, void* nsdata, int length, int mode) |
|||
{ |
|||
NSData* data = (__bridge NSData*)nsdata; |
|||
MultipeerDelegate* delegate = (__bridge MultipeerDelegate*)self; |
|||
NSError* error = [delegate sendToAllPeers:data withMode:(MCSessionSendDataMode)mode]; |
|||
return (__bridge_retained void*)error; |
|||
} |
|||
|
|||
int UnityMC_Delegate_ReceivedDataQueueSize(void* self) |
|||
{ |
|||
if (self == NULL) |
|||
return 0; |
|||
|
|||
MultipeerDelegate* delegate = (__bridge MultipeerDelegate*)self; |
|||
return (int)delegate.queueSize; |
|||
} |
|||
|
|||
void* UnityMC_Delegate_DequeueReceivedData(void* self) |
|||
{ |
|||
MultipeerDelegate* delegate = (__bridge MultipeerDelegate*)self; |
|||
return (__bridge_retained void*)delegate.dequeue; |
|||
} |
|||
|
|||
int UnityMC_Delegate_ConnectedPeerCount(void* self) |
|||
{ |
|||
MultipeerDelegate* delegate = (__bridge MultipeerDelegate*)self; |
|||
return (int)delegate.connectedPeerCount; |
|||
} |
|||
|
|||
void UnityMC_Delegate_SetEnabled(void* self, bool enabled) |
|||
{ |
|||
MultipeerDelegate* delegate = (__bridge MultipeerDelegate*)self; |
|||
delegate.enabled = enabled; |
|||
} |
|||
|
|||
bool UnityMC_Delegate_GetEnabled(void* self) |
|||
{ |
|||
MultipeerDelegate* delegate = (__bridge MultipeerDelegate*)self; |
|||
return delegate.enabled; |
|||
} |
|||
|
|||
void UnityMultipeer_CFRelease(void* ptr) |
|||
{ |
|||
if (ptr) |
|||
{ |
|||
CFRelease(ptr); |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: f94297f07eee14b96b55b6ed49779df0 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import <MultipeerConnectivity/MultipeerConnectivity.h> |
|||
|
|||
@interface MultipeerDelegate : NSObject<MCSessionDelegate, MCNearbyServiceAdvertiserDelegate, MCNearbyServiceBrowserDelegate> |
|||
|
|||
- (nullable instancetype)initWithName:(nonnull NSString *)name serviceType:(nonnull NSString*)serviceType; |
|||
- (nullable NSError*)sendToAllPeers:(nonnull NSData*)data withMode:(MCSessionSendDataMode)mode; |
|||
- (NSUInteger)connectedPeerCount; |
|||
- (NSUInteger)queueSize; |
|||
- (nonnull NSData*)dequeue; |
|||
|
|||
@property BOOL enabled; |
|||
|
|||
@end |
|
|||
fileFormatVersion: 2 |
|||
guid: 598b4c4bd189e49b4b17a87ba0cf5418 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import "MultipeerDelegate.h" |
|||
|
|||
@implementation MultipeerDelegate |
|||
|
|||
MCSession* m_Session; |
|||
MCPeerID* m_PeerID; |
|||
NSMutableArray* m_Queue; |
|||
MCNearbyServiceAdvertiser* m_ServiceAdvertiser; |
|||
MCNearbyServiceBrowser* m_ServiceBrowser; |
|||
BOOL m_Enabled; |
|||
|
|||
- (instancetype)initWithName:(nonnull NSString *)name serviceType:(nonnull NSString *)serviceType |
|||
{ |
|||
if (self = [super init]) |
|||
{ |
|||
m_Enabled = false; |
|||
m_Queue = [[NSMutableArray alloc] init]; |
|||
m_PeerID = [[MCPeerID alloc] initWithDisplayName: name]; |
|||
m_Session = [[MCSession alloc] initWithPeer:m_PeerID |
|||
securityIdentity:nil |
|||
encryptionPreference:MCEncryptionRequired]; |
|||
m_Session.delegate = self; |
|||
|
|||
m_ServiceAdvertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:m_PeerID |
|||
discoveryInfo:nil |
|||
serviceType:serviceType]; |
|||
m_ServiceAdvertiser.delegate = self; |
|||
|
|||
m_ServiceBrowser = [[MCNearbyServiceBrowser alloc] initWithPeer:m_PeerID |
|||
serviceType:serviceType]; |
|||
m_ServiceBrowser.delegate = self; |
|||
} |
|||
|
|||
return self; |
|||
} |
|||
|
|||
- (BOOL)enabled |
|||
{ |
|||
return m_Enabled; |
|||
} |
|||
|
|||
- (void)setEnabled:(BOOL)enabled |
|||
{ |
|||
if (enabled) |
|||
{ |
|||
[m_ServiceAdvertiser startAdvertisingPeer]; |
|||
[m_ServiceBrowser startBrowsingForPeers]; |
|||
} |
|||
else |
|||
{ |
|||
[m_ServiceAdvertiser stopAdvertisingPeer]; |
|||
[m_ServiceBrowser stopBrowsingForPeers]; |
|||
[m_Queue removeAllObjects]; |
|||
} |
|||
|
|||
m_Enabled = enabled; |
|||
} |
|||
|
|||
- (NSError*)sendToAllPeers:(nonnull NSData*)data withMode:(MCSessionSendDataMode)mode |
|||
{ |
|||
if (m_Session.connectedPeers.count == 0) |
|||
return nil; |
|||
|
|||
NSError* error = nil; |
|||
[m_Session sendData:data |
|||
toPeers:m_Session.connectedPeers |
|||
withMode:mode |
|||
error:&error]; |
|||
|
|||
return error; |
|||
} |
|||
|
|||
- (NSUInteger)queueSize |
|||
{ |
|||
return m_Queue.count; |
|||
} |
|||
|
|||
- (nonnull NSData*)dequeue |
|||
{ |
|||
NSData* data = [m_Queue objectAtIndex:0]; |
|||
[m_Queue removeObjectAtIndex:0]; |
|||
return data; |
|||
} |
|||
|
|||
- (NSUInteger)connectedPeerCount |
|||
{ |
|||
return m_Session.connectedPeers.count; |
|||
} |
|||
|
|||
- (void)session:(nonnull MCSession *)session didFinishReceivingResourceWithName:(nonnull NSString *)resourceName fromPeer:(nonnull MCPeerID *)peerID atURL:(nullable NSURL *)localURL withError:(nullable NSError *)error { |
|||
// Not used. |
|||
} |
|||
|
|||
- (void)session:(nonnull MCSession *)session didReceiveData:(nonnull NSData *)data fromPeer:(nonnull MCPeerID *)peerID |
|||
{ |
|||
dispatch_async(dispatch_get_main_queue(), ^{ |
|||
[m_Queue addObject:data]; |
|||
}); |
|||
} |
|||
|
|||
- (void)session:(nonnull MCSession *)session didReceiveStream:(nonnull NSInputStream *)stream withName:(nonnull NSString *)streamName fromPeer:(nonnull MCPeerID *)peerID { |
|||
// Not used. |
|||
} |
|||
|
|||
- (void)session:(nonnull MCSession *)session didStartReceivingResourceWithName:(nonnull NSString *)resourceName fromPeer:(nonnull MCPeerID *)peerID withProgress:(nonnull NSProgress *)progress { |
|||
// Not used. |
|||
} |
|||
|
|||
- (void)session:(nonnull MCSession *)session peer:(nonnull MCPeerID *)peerID didChangeState:(MCSessionState)state { |
|||
// Not used. |
|||
} |
|||
|
|||
- (void)advertiser:(nonnull MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(nonnull MCPeerID *)peerID withContext:(nullable NSData *)context invitationHandler:(nonnull void (^)(BOOL, MCSession * _Nullable))invitationHandler |
|||
{ |
|||
invitationHandler(YES, m_Session); |
|||
} |
|||
|
|||
- (void)browser:(nonnull MCNearbyServiceBrowser *)browser foundPeer:(nonnull MCPeerID *)peerID withDiscoveryInfo:(nullable NSDictionary<NSString *,NSString *> *)info |
|||
{ |
|||
// Invite the peer to join our session |
|||
[browser invitePeer:peerID |
|||
toSession:m_Session |
|||
withContext:nil |
|||
timeout:10]; |
|||
} |
|||
|
|||
- (void)browser:(nonnull MCNearbyServiceBrowser *)browser lostPeer:(nonnull MCPeerID *)peerID |
|||
{ |
|||
// Not used |
|||
} |
|||
|
|||
@end |
|
|||
fileFormatVersion: 2 |
|||
guid: cba1a95445f3e40ac8bbf00450e84734 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
'': Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Android: 1 |
|||
Exclude Editor: 1 |
|||
Exclude Linux: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude LinuxUniversal: 1 |
|||
Exclude Lumin: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
Exclude iOS: 0 |
|||
- first: |
|||
Android: Android |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: ARMv7 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
DefaultValueInitialized: true |
|||
OS: AnyOS |
|||
- first: |
|||
Facebook: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Facebook: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Linux |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86 |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86_64 |
|||
- first: |
|||
Standalone: OSXUniversal |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: |
|||
AddToEmbeddedBinaries: false |
|||
CompileFlags: |
|||
FrameworkDependencies: MultipeerConnectivity; |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import <Foundation/Foundation.h> |
|||
|
|||
int UnityMC_NSData_getLength(void* self) |
|||
{ |
|||
NSData* data = (__bridge NSData*)self; |
|||
return (int)data.length; |
|||
} |
|||
|
|||
void* UnityMC_NSData_createWithBytes(void* bytes, int length) |
|||
{ |
|||
NSData* data = [[NSData alloc] initWithBytes:bytes |
|||
length:length]; |
|||
|
|||
return (__bridge_retained void*)data; |
|||
} |
|||
|
|||
void* UnityMC_NSData_createWithBytesNoCopy(void* bytes, int length, bool freeWhenDone) |
|||
{ |
|||
NSData* data = [[NSData alloc] initWithBytesNoCopy:bytes |
|||
length:length |
|||
freeWhenDone:freeWhenDone]; |
|||
|
|||
return (__bridge_retained void*)data; |
|||
} |
|||
|
|||
const void* UnityMC_NSData_getBytes(void* self) |
|||
{ |
|||
NSData* data = (__bridge NSData*)self; |
|||
return data.bytes; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a452ea1f1d87e4256a5af3b742f78e18 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import <Foundation/Foundation.h> |
|||
|
|||
long UnityMC_NSError_code(void* ptr) |
|||
{ |
|||
return ((__bridge NSError*)ptr).code; |
|||
} |
|||
|
|||
void* UnityMC_NSError_localizedDescription(void* ptr) |
|||
{ |
|||
NSString* desc = ((__bridge NSError*)ptr).localizedDescription; |
|||
return (__bridge_retained void*)desc; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a2cf20442c9d3412f9b1978da0184a7f |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import <Foundation/Foundation.h> |
|||
|
|||
void* UnityMultipeer_NSMutableData_init() |
|||
{ |
|||
NSMutableData* data = [[NSMutableData alloc] init]; |
|||
return (__bridge_retained void*)data; |
|||
} |
|||
|
|||
void* UnityMultipeer_NSMutableData_initWithBytes(const void* bytes, int length) |
|||
{ |
|||
NSMutableData* data = [[NSMutableData alloc] initWithBytes:bytes |
|||
length:length]; |
|||
return (__bridge_retained void*)data; |
|||
} |
|||
|
|||
void* UnityMultipeer_NSMutableData_initWithBytesNoCopy(void* bytes, int length, bool freeWhenDone) |
|||
{ |
|||
NSMutableData* data = [[NSMutableData alloc] initWithBytesNoCopy:bytes |
|||
length:length |
|||
freeWhenDone:freeWhenDone]; |
|||
return (__bridge_retained void*)data; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3fc8bc4bd641e4dfcb418cd41edf6b64 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import <Foundation/Foundation.h> |
|||
|
|||
int UnityMultipeer_NSString_lengthOfBytesUsingEncoding(void* self) |
|||
{ |
|||
if (self == NULL) |
|||
return 0; |
|||
|
|||
NSString* string = (__bridge NSString*)self; |
|||
return (int)[string lengthOfBytesUsingEncoding:NSUTF16LittleEndianStringEncoding]; |
|||
} |
|||
|
|||
bool UnityMultipeer_NSString_getBytes(void* self, void* buffer, int length) |
|||
{ |
|||
NSString* string = (__bridge NSString*)self; |
|||
const NSRange range = NSMakeRange(0, string.length); |
|||
return [string getBytes:buffer |
|||
maxLength:length |
|||
usedLength:NULL |
|||
encoding:NSUTF16LittleEndianStringEncoding |
|||
options:0 |
|||
range:range |
|||
remainingRange:NULL]; |
|||
} |
|||
|
|||
int UnityMultipeer_NSString_getLength(void* self) |
|||
{ |
|||
NSString* string = (__bridge NSString*)self; |
|||
return (int)string.length; |
|||
} |
|||
|
|||
void* UnityMultipeer_NSString_createWithString(void* bytes, int length) |
|||
{ |
|||
NSString* string = [[NSString alloc] initWithBytes: bytes |
|||
length: 2 * length |
|||
encoding: NSUTF16LittleEndianStringEncoding]; |
|||
|
|||
return (__bridge_retained void*)string; |
|||
} |
|||
|
|||
void* UnityMC_NSString_serialize(void* self) |
|||
{ |
|||
NSString* string = (__bridge NSString*)self; |
|||
NSData* data = [NSKeyedArchiver archivedDataWithRootObject:string]; |
|||
return (__bridge_retained void*)data; |
|||
} |
|||
|
|||
void* UnityMC_NSString_deserialize(void* serializedString) |
|||
{ |
|||
NSData* data = (__bridge NSData*)serializedString; |
|||
NSString* string = [NSKeyedUnarchiver unarchiveObjectWithData:data]; |
|||
return (__bridge_retained void*)string; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f45e73c2d697643c898c3f259d718667 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using NSData = Unity.iOS.Multipeer.NSData; |
|||
|
|||
namespace UnityEngine.XR.ARKit |
|||
{ |
|||
public static class SerializedARCollaborationDataExtensions |
|||
{ |
|||
public static unsafe NSData ToNSData(this SerializedARCollaborationData serializedData) |
|||
{ |
|||
return *(NSData*)&serializedData; |
|||
} |
|||
|
|||
public static unsafe SerializedARCollaborationData ToSerializedCollaborationData(this NSData data) |
|||
{ |
|||
return *(SerializedARCollaborationData*)&data; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5c7401124c8aa4055a1aa40c18eed44b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue