|
|
|
@ -20,10 +20,15 @@ using LoginOptions = Epic.OnlineServices.Auth.LoginOptions; |
|
|
|
#if UNITY_GAMECORE
|
|
|
|
using Unity.GameCore; |
|
|
|
using UnityEngine.GameCore; |
|
|
|
#elif UNITY_PS4
|
|
|
|
using PSInput = UnityEngine.PS4.PS4Input; |
|
|
|
#elif UNITY_PS5
|
|
|
|
using PSInput = UnityEngine.PS5.PS5Input; |
|
|
|
#elif UNITY_PS4 || UNITY_PS5
|
|
|
|
using Unity.PSN.PS5; |
|
|
|
using Unity.PSN.PS5.Auth; |
|
|
|
using Unity.PSN.PS5.Aysnc; |
|
|
|
#if UNITY_PS4
|
|
|
|
using PSInput = UnityEngine.PS4.PS4Input; |
|
|
|
#elif UNITY_PS5
|
|
|
|
using PSInput = UnityEngine.PS5.PS5Input; |
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
public class EpicVoiceChatTest : MonoBehaviour |
|
|
|
@ -51,6 +56,7 @@ public class EpicVoiceChatTest : MonoBehaviour |
|
|
|
private EOSVoiceChat voiceChat; |
|
|
|
|
|
|
|
private string xstsToken; |
|
|
|
private string psnToken; |
|
|
|
|
|
|
|
private string XAudio29DllPath => |
|
|
|
#if UNITY_EDITOR
|
|
|
|
@ -89,6 +95,29 @@ public class EpicVoiceChatTest : 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); |
|
|
|
#elif UNITY_PS4 || UNITY_PS5
|
|
|
|
try |
|
|
|
{ |
|
|
|
var initResult = Main.Initialize(); |
|
|
|
if (initResult.Initialized) |
|
|
|
{ |
|
|
|
Debug.Log($"PSN Initialized\nPlugin SDK Version: {initResult.SceSDKVersion}"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Debug.LogWarning("PSN not initialized!"); |
|
|
|
yield break; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (PSNException ex) |
|
|
|
{ |
|
|
|
Debug.LogError("Exception during PSN initialization: " + ex.ExtendedMessage); |
|
|
|
Debug.LogException(ex); |
|
|
|
yield break; |
|
|
|
} |
|
|
|
|
|
|
|
// This delay is just here to give us some time to connect the debugger
|
|
|
|
yield return new WaitForSeconds(5f); |
|
|
|
#endif
|
|
|
|
@ -97,7 +126,7 @@ public class EpicVoiceChatTest : MonoBehaviour |
|
|
|
{ |
|
|
|
ProductName = "WW1Test", |
|
|
|
ProductVersion = "1.0.0.0", |
|
|
|
#if UNITY_GAMECORE
|
|
|
|
#if UNITY_GAMECORE || UNITY_PS4 || UNITY_PS5
|
|
|
|
// 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), |
|
|
|
@ -231,12 +260,38 @@ public class EpicVoiceChatTest : MonoBehaviour |
|
|
|
#elif UNITY_PS4 || UNITY_PS5
|
|
|
|
var loggedInUser = PSInput.RefreshUsersDetails(0); |
|
|
|
|
|
|
|
// TODO: this needs to be a GetIdTokenRequest with client ID, client secret and "openid id_token:basic_claims" as the scope
|
|
|
|
var request = new Authentication.GetAuthorizationCodeRequest |
|
|
|
{ |
|
|
|
UserId = loggedInUser.userId, |
|
|
|
ClientId = "83c6530f-741e-45ff-af3a-ddb90628a928", |
|
|
|
Scope = "psn:s2s", |
|
|
|
}; |
|
|
|
|
|
|
|
var requestOp = new AsyncRequest<Authentication.GetAuthorizationCodeRequest>(request) |
|
|
|
.ContinueWith(antecedent => |
|
|
|
{ |
|
|
|
if (antecedent?.Request == null || antecedent.Request.Result.apiResult != APIResultTypes.Success) |
|
|
|
{ |
|
|
|
Debug.LogError($"PSN authentication failed, error = {antecedent?.Request?.Result.ErrorMessage()}"); |
|
|
|
status.AppendLine("PSN authentication failed..."); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
status.AppendLine("PSN authenticated"); |
|
|
|
psnToken = antecedent.Request.AuthCode; |
|
|
|
}); |
|
|
|
|
|
|
|
Authentication.Schedule(requestOp); |
|
|
|
|
|
|
|
yield return new WaitUntil(() => !string.IsNullOrEmpty(psnToken)); |
|
|
|
|
|
|
|
connectInterface.Login(new Epic.OnlineServices.Connect.LoginOptions |
|
|
|
{ |
|
|
|
Credentials = new Epic.OnlineServices.Connect.Credentials |
|
|
|
{ |
|
|
|
Type = ExternalCredentialType.PsnIdToken, |
|
|
|
Token = "", // TODO: authenticate from PSN
|
|
|
|
Token = psnToken, |
|
|
|
}, |
|
|
|
}, null, HandleConnectResult); |
|
|
|
#else
|
|
|
|
@ -368,6 +423,8 @@ public class EpicVoiceChatTest : MonoBehaviour |
|
|
|
|
|
|
|
#if UNITY_GAMECORE
|
|
|
|
SDK.XTaskQueueDispatch(); |
|
|
|
#elif UNITY_PS4 || UNITY_PS5
|
|
|
|
Main.Update(); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
|