Skip to content

Commit 99f99b2

Browse files
authored
EOS Disable and Bindings Fix (#12)
1 parent b11fb46 commit 99f99b2

File tree

4 files changed

+71
-53
lines changed

4 files changed

+71
-53
lines changed

Editor/EditorWindows/EncryptionKeyWindow.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ public EncryptionKeyWindow() : base("Client Credential Encryption Key", 600f, 50
4848
/// </param>
4949
public static void Show(string input, Action<string> onSubmitCallback)
5050
{
51-
ScheduleShow<EncryptionKeyWindow>(
52-
input,
53-
onSubmitCallback,
54-
EOSClientCredentials.IsEncryptionKeyValid,
55-
"Enter the encryption key for these client credentials here:",
56-
"Invalid encryption key. Encryption key must be 64 characters long and contain only alphanumeric characters.");
51+
#if !EOS_DISABLE
52+
ScheduleShow<EncryptionKeyWindow>(
53+
input,
54+
onSubmitCallback,
55+
EOSClientCredentials.IsEncryptionKeyValid,
56+
"Enter the encryption key for these client credentials here:",
57+
"Invalid encryption key. Encryption key must be 64 characters long and contain only alphanumeric characters.");
58+
#else
59+
Debug.LogWarning("EOS SDK is disabled. Encryption key window is not available.");
60+
#endif
5761
}
5862

5963
/// <summary>
@@ -63,16 +67,25 @@ protected override void RenderModalContents()
6367
{
6468
GUILayout.BeginHorizontal();
6569

66-
_input = GUILayout.TextField(_input, GUILayout.Width(GUIEditorUtility.MeasureLabelWidth(64)), GUILayout.Height(20));
70+
_input = GUILayout.TextField(
71+
_input,
72+
GUILayout.Width(EditorStyles.label.CalcSize(new GUIContent("Encryption Key")).x),
73+
GUILayout.Height(20));
6774

6875
GUILayout.Space(5f);
6976

70-
if (GUILayout.Button(
71-
new GUIContent(EditorGUIUtility.IconContent("Refresh").image,
72-
"Click here to generate a new encryption key."), GUILayout.Height(20), GUILayout.Width(50)))
73-
{
74-
_input = EOSClientCredentials.GenerateEncryptionKey();
75-
}
77+
#if !EOS_DISABLE
78+
if (GUILayout.Button(
79+
new GUIContent(EditorGUIUtility.IconContent("Refresh").image,
80+
"Click here to generate a new encryption key."),
81+
GUILayout.Height(20), GUILayout.Width(50)))
82+
{
83+
_input = EOSClientCredentials.GenerateEncryptionKey();
84+
}
85+
#else
86+
GUILayout.Label("EOS SDK is disabled.");
87+
#endif
88+
7689
GUILayout.EndHorizontal();
7790
}
7891
}

Editor/EditorWindows/ModalEOSEditorWindow.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ protected override void RenderWindow()
189189
bool shouldClose = false;
190190

191191
// Render the prompt text
192-
EditorGUILayout.LabelField(_inputPrompt, GUILayout.Width(
193-
GUIEditorUtility.MeasureLabelWidth(_inputPrompt))
194-
);
192+
EditorGUILayout.LabelField(_inputPrompt, GUILayout.Width(EditorStyles.label.CalcSize(new GUIContent(_inputPrompt)).x));
195193

196194
// Display error if it needs to be displayed.
197195
if (_showError)

Runtime/Core/EOSManager.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,7 @@ enum EOSState
184184
static private bool s_isConstrained = true;
185185
static public bool ApplicationIsConstrained { get => s_isConstrained; }
186186

187-
/// <summary>
188-
/// Actions that need to be executed on the main thread.
189-
/// Lazy allocated in <see cref="DispatchAsync"/>.
190-
/// </summary>
191-
private static List<Action> s_enqueuedTasks;
192187

193-
/// <summary>
194-
/// Locak object used for <see cref="s_enqueuedTasks"/>, such that it can
195-
/// be executed thread-safe way.
196-
/// </summary>
197-
private static System.Object s_enqueuedTasksLock = new System.Object();
198188
//private static List
199189

200190
//-------------------------------------------------------------------------
@@ -1844,6 +1834,18 @@ static public EOSSingleton Instance
18441834
}
18451835
}
18461836

1837+
/// <summary>
1838+
/// Actions that need to be executed on the main thread.
1839+
/// Lazy allocated in <see cref="DispatchAsync"/>.
1840+
/// </summary>
1841+
private static List<Action> s_enqueuedTasks;
1842+
1843+
/// <summary>
1844+
/// Locak object used for <see cref="s_enqueuedTasks"/>, such that it can
1845+
/// be executed thread-safe way.
1846+
/// </summary>
1847+
private static System.Object s_enqueuedTasksLock = new System.Object();
1848+
18471849
#if !EOS_DISABLE
18481850
//-------------------------------------------------------------------------
18491851
/// <summary>Unity [Awake](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html) is called when script instance is being loaded.

Runtime/EOS_SDK/Generated/Bindings.cs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,62 @@
22
// This file is automatically generated. Changes to this file may be overwritten.
33

44
#if DEBUG
5-
#define EOS_DEBUG
5+
#define EOS_DEBUG
66
#endif
77

88
#if UNITY_EDITOR
9-
#define EOS_EDITOR
9+
#define EOS_EDITOR
1010
#endif
1111

1212
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_PS4 || UNITY_XBOXONE || UNITY_SWITCH || UNITY_IOS || UNITY_ANDROID
13-
#define EOS_UNITY
13+
#define EOS_UNITY
1414
#endif
1515

1616
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || PLATFORM_64BITS || PLATFORM_32BITS
17-
#if UNITY_EDITOR_WIN || UNITY_64 || PLATFORM_64BITS
18-
#define EOS_PLATFORM_WINDOWS_64
19-
#else
20-
#define EOS_PLATFORM_WINDOWS_32
21-
#endif
17+
#if UNITY_EDITOR_WIN || UNITY_64 || PLATFORM_64BITS
18+
#define EOS_PLATFORM_WINDOWS_64
19+
#else
20+
#define EOS_PLATFORM_WINDOWS_32
21+
#endif
2222

2323
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
24-
#define EOS_PLATFORM_OSX
24+
#define EOS_PLATFORM_OSX
25+
26+
#elif UNITY_EDITOR_OSX
27+
#define EOS_PLATFORM_OSX_INEDITOR
2528

2629
#elif UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
27-
#define EOS_PLATFORM_LINUX
30+
#define EOS_PLATFORM_LINUX
2831

2932
#elif UNITY_PS4
30-
#define EOS_PLATFORM_PS4
33+
#define EOS_PLATFORM_PS4
3134

3235
#elif UNITY_XBOXONE
33-
#define EOS_PLATFORM_XBOXONE
36+
#define EOS_PLATFORM_XBOXONE
3437

3538
#elif UNITY_SWITCH
36-
#define EOS_PLATFORM_SWITCH
39+
#define EOS_PLATFORM_SWITCH
3740

3841
#elif UNITY_IOS || __IOS__
39-
#define EOS_PLATFORM_IOS
42+
#define EOS_PLATFORM_IOS
4043

4144
#elif UNITY_ANDROID || __ANDROID__
42-
#define EOS_PLATFORM_ANDROID
45+
#define EOS_PLATFORM_ANDROID
4346

4447
#endif
4548

4649
#if EOS_EDITOR
47-
#define EOS_DYNAMIC_BINDINGS
50+
#define EOS_DYNAMIC_BINDINGS
4851
#endif
4952

5053
#if EOS_DYNAMIC_BINDINGS
51-
#if EOS_PLATFORM_WINDOWS_32
52-
#define EOS_DYNAMIC_BINDINGS_NAME_TYPE3
53-
#elif EOS_PLATFORM_OSX
54-
#define EOS_DYNAMIC_BINDINGS_NAME_TYPE2
55-
#else
56-
#define EOS_DYNAMIC_BINDINGS_NAME_TYPE1
57-
#endif
54+
#if EOS_PLATFORM_WINDOWS_32
55+
#define EOS_DYNAMIC_BINDINGS_NAME_TYPE3
56+
#elif EOS_PLATFORM_OSX
57+
#define EOS_DYNAMIC_BINDINGS_NAME_TYPE2
58+
#else
59+
#define EOS_DYNAMIC_BINDINGS_NAME_TYPE1
60+
#endif
5861
#endif
5962

6063
using System;
@@ -2141,9 +2144,11 @@ public static void Hook<TLibraryHandle>(TLibraryHandle libraryHandle, Func<TLibr
21412144
if (functionPointer == System.IntPtr.Zero) throw new DynamicBindingException(EOS_AntiCheatClient_RemoveNotifyPeerAuthStatusChangedName);
21422145
EOS_AntiCheatClient_RemoveNotifyPeerAuthStatusChanged = (EOS_AntiCheatClient_RemoveNotifyPeerAuthStatusChangedDelegate)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(EOS_AntiCheatClient_RemoveNotifyPeerAuthStatusChangedDelegate));
21432146

2147+
#if EOS_PLATFORM_OSX_INEDITOR
21442148
functionPointer = getFunctionPointer(libraryHandle, EOS_AntiCheatClient_Reserved01Name);
21452149
if (functionPointer == System.IntPtr.Zero) throw new DynamicBindingException(EOS_AntiCheatClient_Reserved01Name);
21462150
EOS_AntiCheatClient_Reserved01 = (EOS_AntiCheatClient_Reserved01Delegate)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(EOS_AntiCheatClient_Reserved01Delegate));
2151+
#endif
21472152

21482153
functionPointer = getFunctionPointer(libraryHandle, EOS_AntiCheatClient_UnprotectMessageName);
21492154
if (functionPointer == System.IntPtr.Zero) throw new DynamicBindingException(EOS_AntiCheatClient_UnprotectMessageName);
@@ -4468,10 +4473,10 @@ public static void Hook<TLibraryHandle>(TLibraryHandle libraryHandle, Func<TLibr
44684473
#endif
44694474

44704475
#if EOS_DYNAMIC_BINDINGS
4471-
/// <summary>
4472-
/// Unhooks the dynamic SDK API bindings. EOS_DYNAMIC_BINDINGS or EOS_EDITOR must be set.
4473-
/// </summary>
4474-
public static void Unhook()
4476+
/// <summary>
4477+
/// Unhooks the dynamic SDK API bindings. EOS_DYNAMIC_BINDINGS or EOS_EDITOR must be set.
4478+
/// </summary>
4479+
public static void Unhook()
44754480
{
44764481
EOS_Achievements_AddNotifyAchievementsUnlocked = null;
44774482
EOS_Achievements_AddNotifyAchievementsUnlockedV2 = null;

0 commit comments

Comments
 (0)