Skip to content

Commit

Permalink
Merge pull request #18 from modio/v2024.11
Browse files Browse the repository at this point in the history
Syncing v2024.11
  • Loading branch information
johnw-modio authored Dec 10, 2024
2 parents 38efd3b + 48405a6 commit 589445d
Show file tree
Hide file tree
Showing 135 changed files with 5,062 additions and 367 deletions.
13 changes: 11 additions & 2 deletions Editor/ModIO.EditorCode/SettingsAssetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SettingsAssetEditor : Editor
SerializedProperty useCommandLineArgumentOverrides;
SerializedProperty _showMonetizationUIProperty;
SerializedProperty _showEnabledModToggleProperty;
SerializedProperty _fallbackToEmailProperty;

void OnEnable()
{
Expand All @@ -29,6 +30,7 @@ void OnEnable()
var uiSettingsProperty = serializedObject.FindProperty("uiSettings");

_showMonetizationUIProperty = uiSettingsProperty.FindPropertyRelative("ShowMonetizationUI");
_fallbackToEmailProperty = serverSettingsProperty.FindPropertyRelative("fallbackToEmailAuth");
_showEnabledModToggleProperty = uiSettingsProperty.FindPropertyRelative("ShowEnabledModToggle");
}

Expand Down Expand Up @@ -58,13 +60,20 @@ public override void OnInspectorGUI()
EditorGUILayout.Space();

EditorGUILayout.DelayedIntField(gameId, new GUIContent("Game ID"));

using (EditorGUI.ChangeCheckScope passwordChange = new EditorGUI.ChangeCheckScope())
{
string tempPassword = EditorGUILayout.PasswordField("API Key", gameKey.stringValue);
if (passwordChange.changed)
gameKey.stringValue = tempPassword;
}

EditorGUILayout.PropertyField(_fallbackToEmailProperty);
if (_fallbackToEmailProperty.boolValue)
{
EditorGUILayout.HelpBox("This may cause certification failures on platforms", MessageType.Warning);
}

if (myTarget.serverSettings.gameId == 0 || string.IsNullOrWhiteSpace(myTarget.serverSettings.gameKey))
{
EditorGUILayout.Space();
Expand Down Expand Up @@ -108,7 +117,7 @@ public override void OnInspectorGUI()

EditorGUILayout.BeginHorizontal();

if (GUILayout.Button("Insert URL for Test API"))
if (GUILayout.Button("Insert URL for Staging API"))
SetURLTest();

if (GUILayout.Button("Insert URL for Production API"))
Expand Down Expand Up @@ -153,7 +162,7 @@ void SetURLTest()

internal static string GetURLProduction(int gameId) => $"https://g-{gameId}.modapi.io/v1";

static string GetURLTest(int gameId) => "https://api.test.mod.io/v1";
static string GetURLTest(int gameId) => "https://api-staging.moddemo.io/v1";

static bool IsURLProduction(string url) => Regex.IsMatch(url, @"https:\/\/g-\d*.modapi.io\/v1");
}
Expand Down
Binary file modified Experimental/modio-ui.unitypackage
Binary file not shown.
6 changes: 3 additions & 3 deletions Platform/Mobile/Android/ModioPlatformExampleGoogleGames.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UnityEngine;

#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
using GooglePlayGames;
#endif

Expand All @@ -10,11 +10,11 @@ public class ModioPlatformExampleGoogleGames : MonoBehaviour
{
private void Awake()
{
#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
// Enable debug logging for Play Games Platform
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();

// Authenticate with Play Games Services
PlayGamesPlatform.Instance.Authenticate((success) =>
{
Expand Down
6 changes: 3 additions & 3 deletions Platform/Mobile/Android/ModioPlatformExampleGoogleSignIn.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UnityEngine;

#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand All @@ -16,12 +16,12 @@ public class ModioPlatformExampleGoogleSignIn : MonoBehaviour

private void Awake()
{
#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
SignInSilently();
#endif
}

#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
async void SignInSilently()
{
if (Application.isEditor)
Expand Down
10 changes: 5 additions & 5 deletions Platform/Mobile/Android/ModioPlatformGoogleGames.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
using GooglePlayGames;
using UnityEngine;
#endif
Expand All @@ -13,10 +13,10 @@ public static void SetAsPlatform()
{
ActivePlatform = new ModioPlatformGoogleGames();
}

public void PerformSso(TermsHash? displayedTerms, Action<Result> onComplete, string optionalThirdPartyEmailAddressUsedForAuthentication = null)
{
#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
GetIdToken(token =>
{
ModIOUnity.AuthenticateUserViaGoogle(token,
Expand All @@ -26,8 +26,8 @@ public void PerformSso(TermsHash? displayedTerms, Action<Result> onComplete, str
});
#endif
}
#if UNITY_ANDROID

#if UNITY_ANDROID && !MODIO_OCULUS
void GetIdToken(Action<string> onReceivedAuthCode)
{
if (Application.isEditor)
Expand Down
4 changes: 2 additions & 2 deletions Platform/Mobile/Android/ModioPlatformGoogleSignIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace ModIO.Implementation.Platform
public class ModioPlatformGoogleSignIn : ModioPlatform, IModioSsoPlatform
{
private string idToken;

public static void SetAsPlatform(string idToken)
{
ActivePlatform = new ModioPlatformGoogleSignIn
Expand All @@ -15,7 +15,7 @@ public static void SetAsPlatform(string idToken)
}
public void PerformSso(TermsHash? displayedTerms, Action<Result> onComplete, string optionalThirdPartyEmailAddressUsedForAuthentication = null)
{
#if UNITY_ANDROID
#if UNITY_ANDROID && !MODIO_OCULUS
ModIOUnity.AuthenticateUserViaGoogle(idToken,
optionalThirdPartyEmailAddressUsedForAuthentication,
displayedTerms,
Expand Down
25 changes: 23 additions & 2 deletions Platform/Mobile/iOS/ModioPlatformIos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;

#if UNITY_IOS
using ModIO.Platform.Mobile.iOS;
using AppleAuth;
using AppleAuth.Enums;
using AppleAuth.Extensions;
Expand Down Expand Up @@ -46,15 +47,35 @@ void GetToken(Action<string> onReceivedIdToken)
}
}
#endif
public override bool TryGetAvailableDiskSpace(out long availableFreeSpace)
{
#if UNITY_IOS
try
{
availableFreeSpace = NativeIosBridge.GetAvailableDiskSpace();
return true;
}
catch (Exception e)
{
availableFreeSpace = 0;
Logger.Log(LogLevel.Error, $"An Error occurred when trying to get available disk space. {e}");
return false;
}
#else
availableFreeSpace = 0;
return false;
#endif

}
public void PerformSso(TermsHash? displayedTerms, Action<Result> onComplete,
string optionalThirdPartyEmailAddressUsedForAuthentication = null)
string optionalThirdPartyEmailAddressUsedForAuthentication = null)
{
#if UNITY_IOS
GetToken((idToken) =>
{
ModIOUnity.AuthenticateUserViaApple(idToken,
optionalThirdPartyEmailAddressUsedForAuthentication,
displayedTerms,
displayedTerms,
onComplete);
});
#endif
Expand Down
14 changes: 14 additions & 0 deletions Platform/Mobile/iOS/NativeIosBridge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Runtime.InteropServices;

namespace ModIO.Platform.Mobile.iOS
{
#if UNITY_IOS

public static class NativeIosBridge
{
[DllImport("__Internal")]
public static extern long GetAvailableDiskSpace();
}
#endif

}
11 changes: 11 additions & 0 deletions Platform/Mobile/iOS/NativeIosBridge.cs.meta

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

3 changes: 3 additions & 0 deletions Platform/Oculus.meta

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

50 changes: 50 additions & 0 deletions Platform/Oculus/ModioPlatformExampleOculus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using UnityEngine;

#if MODIO_OCULUS
using Oculus.Platform;
using Oculus.Platform.Models;
#endif

namespace ModIO.Implementation.Platform
{
public class ModioPlatformExampleOculus : MonoBehaviour
{
#if MODIO_OCULUS
void Awake()
{
// Oculus takes a fair bit of time to initialize and perform the entitlement check. By calling this
// we're telling the plugin to wait until it's ready.
ModioPlatform.SetInitializing();

// Ensure you have your game's App Id set up in the Oculus Settings object provided by the Meta Platform SDK
Core.AsyncInitialize().OnComplete(OnInitialize);
}

void OnInitialize(Message<PlatformInitialize> message)
{
if (message.IsError)
{
Logger.Log(LogLevel.Error, $"initializing Oculus Platform: {message.GetError().Message}");
return;
}

Logger.Log(LogLevel.Verbose, $"Oculus Platform initialized successfully");

Entitlements.IsUserEntitledToApplication().OnComplete(OnEntitled);
}

void OnEntitled(Message message)
{
if (message.IsError)
{
Logger.Log(LogLevel.Error, $"Error checking Oculus Platform entitlement: {message.GetError().Message}");
return;
}

Logger.Log(LogLevel.Verbose, $"Oculus Platform verified entitlement successfully");

ModioPlatformOculus.SetAsPlatform();
}
#endif
}
}
3 changes: 3 additions & 0 deletions Platform/Oculus/ModioPlatformExampleOculus.cs.meta

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

Loading

0 comments on commit 589445d

Please sign in to comment.