diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity
index 6f6fb56..1b49cfe 100644
--- a/Assets/Scenes/SampleScene.unity
+++ b/Assets/Scenes/SampleScene.unity
@@ -307,7 +307,7 @@ GameObject:
- component: {fileID: 1498573725}
- component: {fileID: 1498573724}
m_Layer: 0
- m_Name: Magnificent Voice Chat
+ m_Name: Epic Voice Chat Test
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
diff --git a/Assets/Scripts/EOSNativeHelper.cs b/Assets/Scripts/EOSNativeHelper.cs
index 1388d8e..80c8fbb 100644
--- a/Assets/Scripts/EOSNativeHelper.cs
+++ b/Assets/Scripts/EOSNativeHelper.cs
@@ -37,6 +37,7 @@ public static class EOSNativeHelper
public static IntPtr AllocateMemory(IntPtr size, IntPtr alignment)
{
return Marshal.AllocHGlobal(size);
+ //return HeapAlloc(GetProcessHeap(), 0, size);
}
[UnmanagedFunctionPointer(Config.LibraryCallingConvention)]
@@ -45,10 +46,16 @@ public static class EOSNativeHelper
[MonoPInvokeCallback(typeof(ReallocateMemoryFunc))]
public static IntPtr ReallocateMemory(IntPtr pointer, IntPtr size, IntPtr alignment)
{
+ // EOS will sometimes request a reallocation for a null pointer, so we need to specifically handle that
if (pointer == IntPtr.Zero)
return Marshal.AllocHGlobal(size);
return Marshal.ReAllocHGlobal(pointer, size);
+
+ // if (pointer == IntPtr.Zero)
+ // return HeapAlloc(GetProcessHeap(), 0, size);
+ //
+ // return HeapReAlloc(GetProcessHeap(), 0, pointer, size);
}
[UnmanagedFunctionPointer(Config.LibraryCallingConvention)]
@@ -58,5 +65,19 @@ public static class EOSNativeHelper
public static void ReleaseMemory(IntPtr pointer)
{
Marshal.FreeHGlobal(pointer);
+ // HeapFree(GetProcessHeap(), 0, pointer);
}
+
+ [DllImport("kernel32", SetLastError = true)]
+ private static extern IntPtr GetProcessHeap();
+
+ [DllImport("kernel32")]
+ private static extern IntPtr HeapAlloc(IntPtr hHeap, int dwFlags, IntPtr dwBytes);
+
+ [DllImport("kernel32")]
+ private static extern IntPtr HeapReAlloc(IntPtr hHeap, int dwFlags, IntPtr lpMem, IntPtr dwBytes);
+
+ [DllImport("kernel32")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool HeapFree(IntPtr hHeap, int dwFlags, IntPtr lpMem);
}
diff --git a/Assets/Scripts/EOSVoiceChat.cs b/Assets/Scripts/EOSVoiceChat.cs
index 2f08284..fd152ff 100644
--- a/Assets/Scripts/EOSVoiceChat.cs
+++ b/Assets/Scripts/EOSVoiceChat.cs
@@ -63,7 +63,6 @@ public class EOSVoiceChat: IDisposable
///
/// Join an existing chat lobby or create a new one.
- /// The completion callback is invoked on both success and failure, and can be used to set up the chat lobby's initial parameters.
///
public void ConnectToChat(string chatLobbyName, uint maxChatPlayers = DefaultMaxChatPlayers)
{
@@ -330,10 +329,14 @@ public class EOSVoiceChat: IDisposable
// Update the default input device, so we know whether we can actually talk or not
uint inputDevicesCount = audioInterface.GetAudioInputDevicesCount(new GetAudioInputDevicesCountOptions());
+ Debug.Log($"Found {inputDevicesCount} input device(s)");
+
for (uint inputDeviceIndex = 0; inputDeviceIndex < inputDevicesCount; ++inputDeviceIndex)
{
var inputDeviceInfo = audioInterface.GetAudioInputDeviceByIndex(
new GetAudioInputDeviceByIndexOptions { DeviceInfoIndex = inputDeviceIndex });
+
+ Debug.Log($"Input device {inputDeviceIndex}: ID = {inputDeviceInfo.DeviceId}, Name = {inputDeviceInfo.DeviceName}, Default = {inputDeviceInfo.DefaultDevice}");
if (inputDeviceInfo.DefaultDevice)
{
diff --git a/Assets/Scripts/MagnificentVoiceChat.cs b/Assets/Scripts/EpicVoiceChatTest.cs
similarity index 93%
rename from Assets/Scripts/MagnificentVoiceChat.cs
rename to Assets/Scripts/EpicVoiceChatTest.cs
index 444719a..cf125c4 100644
--- a/Assets/Scripts/MagnificentVoiceChat.cs
+++ b/Assets/Scripts/EpicVoiceChatTest.cs
@@ -22,10 +22,12 @@ using Unity.GameCore;
using UnityEngine.GameCore;
#endif
-public class MagnificentVoiceChat : MonoBehaviour
+public class EpicVoiceChatTest : MonoBehaviour
{
+ // We intend to use predetermined lobby names generated from game-specific match/team/squad information,
+ // so to simulate this we use a static GUID here, as opposed to letting Epic's backend automatically generate a random lobby ID.
+ // This also allows multiple clients to connect to the same lobby without having to communicate the ID among each other.
private const string DebugLobbyId = "a0f6a51f-6b61-4c95-9ed8-a1d508fe4eb6";
- private const string DebugBucketId = "foobar";
private readonly StringBuilder status = new StringBuilder("Status:\n");
@@ -80,6 +82,7 @@ public class MagnificentVoiceChat : MonoBehaviour
Debug.Log("Xbox Live services initialized.");
+ // This delay is just here to give us some time to connect the debugger
yield return new WaitForSeconds(5f);
#endif
@@ -88,6 +91,7 @@ public class MagnificentVoiceChat : MonoBehaviour
ProductName = "WW1Test",
ProductVersion = "1.0.0.0",
#if UNITY_GAMECORE
+ // EOS SDK on Game Core will not initialize without these memory management function pointers
AllocateMemoryFunction = Marshal.GetFunctionPointerForDelegate((EOSNativeHelper.AllocateMemoryFunc)EOSNativeHelper.AllocateMemory),
ReallocateMemoryFunction = Marshal.GetFunctionPointerForDelegate((EOSNativeHelper.ReallocateMemoryFunc)EOSNativeHelper.ReallocateMemory),
ReleaseMemoryFunction = Marshal.GetFunctionPointerForDelegate((EOSNativeHelper.ReleaseMemoryFunc)EOSNativeHelper.ReleaseMemory),
@@ -368,12 +372,14 @@ public class MagnificentVoiceChat : MonoBehaviour
private void LoadLibrary()
{
+ // EOS SDK 1.13 uses dynamic library binding in the Editor but does not provide any system functions to actually load dynamic libraries,
+ // so we need to provide those ourselves.
eosLbraryHandle = EOSNativeHelper.LoadLibrary($@"Assets\Plugins\EpicOnlineServices\Bin\{Config.LibraryName}.dll");
if (eosLbraryHandle == IntPtr.Zero)
{
throw new Exception("Could not load EOS library!");
}
-
+
Bindings.Hook(eosLbraryHandle, EOSNativeHelper.GetProcAddress);
Debug.Log("Hooked EOS library bindings");
@@ -413,7 +419,12 @@ public class MagnificentVoiceChat : MonoBehaviour
private void OnGUI()
{
- GUI.matrix = Matrix4x4.Scale(new Vector3(2, 2, 1));
+ int screenHeight = Screen.currentResolution.height;
+ if (screenHeight == 0)
+ screenHeight = 1080;
+
+ float screenScale = screenHeight / 720f;
+ GUI.matrix = Matrix4x4.Scale(new Vector3(screenScale, screenScale, 1));
GUILayout.Label(status.ToString());
}
diff --git a/Assets/Scripts/MagnificentVoiceChat.cs.meta b/Assets/Scripts/EpicVoiceChatTest.cs.meta
similarity index 100%
rename from Assets/Scripts/MagnificentVoiceChat.cs.meta
rename to Assets/Scripts/EpicVoiceChatTest.cs.meta
diff --git a/Assets/Scripts/IProductUserMapper.cs b/Assets/Scripts/IProductUserMapper.cs
deleted file mode 100644
index 36ed9ca..0000000
--- a/Assets/Scripts/IProductUserMapper.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using Epic.OnlineServices;
-
-///
-/// Generic interface for converting between EOS Product Users and platform-specific Player IDs.
-/// The exact rules for mapping from one to the other may differ per platform, e.g. Steam and Epic will use different logic than Xbox and PlayStation.
-/// The methods in this interface are asynchronous, though implementations may choose to pre-cache mappings to speed up the process.
-///
-public interface IProductUserMapper
-{
- void MapProductUserToPlatformId(ProductUserId productUserId, Action platformIdCallback);
- void MapPlatformIdToProductUser(string platformId, Action productUserCallback);
-}
diff --git a/Assets/Scripts/IProductUserMapper.cs.meta b/Assets/Scripts/IProductUserMapper.cs.meta
deleted file mode 100644
index dca9303..0000000
--- a/Assets/Scripts/IProductUserMapper.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: d8a80c90c491474dbe97eba62578254f
-timeCreated: 1625665094
\ No newline at end of file
diff --git a/Packages/gamecore/com.unity.gamecore-0.4.6-preview.tgz b/Packages/gamecore/com.unity.gamecore-0.4.6-preview.tgz
new file mode 100644
index 0000000..8556814
Binary files /dev/null and b/Packages/gamecore/com.unity.gamecore-0.4.6-preview.tgz differ
diff --git a/Packages/manifest.json b/Packages/manifest.json
index 5601db6..1e461ab 100644
--- a/Packages/manifest.json
+++ b/Packages/manifest.json
@@ -1,6 +1,7 @@
{
"dependencies": {
"com.unity.collab-proxy": "1.2.16",
+ "com.unity.gamecore": "file:gamecore/com.unity.gamecore-0.4.6-preview.tgz",
"com.unity.ide.rider": "1.2.1",
"com.unity.ide.vscode": "1.2.3",
"com.unity.test-framework": "1.1.24",
diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json
index 071048e..8e1ebbe 100644
--- a/Packages/packages-lock.json
+++ b/Packages/packages-lock.json
@@ -14,6 +14,12 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
+ "com.unity.gamecore": {
+ "version": "file:gamecore/com.unity.gamecore-0.4.6-preview.tgz",
+ "depth": 0,
+ "source": "local-tarball",
+ "dependencies": {}
+ },
"com.unity.ide.rider": {
"version": "1.2.1",
"depth": 0,