Skip to content

Commit fe41eb3

Browse files
committed
feat: Introduce BeforeWrite hook - and override the implementation within ProductConfig to properly associate the first sandbox and deployments added.
1 parent 75fbca5 commit fe41eb3

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

com.playeveryware.eos/Runtime/Core/Config/Config.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ private async Task EnsureConfigFileExistsAsync()
499499
/// <returns>Task</returns>
500500
public virtual async Task WriteAsync(bool prettyPrint = true)
501501
{
502+
BeforeWrite();
503+
502504
// Set the schema version to the current before writing.
503505
schemaVersion = CURRENT_SCHEMA_VERSION;
504506

@@ -521,6 +523,8 @@ public virtual async Task WriteAsync(bool prettyPrint = true)
521523
/// </param>
522524
public virtual void Write(bool prettyPrint = true)
523525
{
526+
BeforeWrite();
527+
524528
// Set the schema version to the current before writing.
525529
schemaVersion = CURRENT_SCHEMA_VERSION;
526530

@@ -535,6 +539,12 @@ public virtual void Write(bool prettyPrint = true)
535539
OnWriteCompleted();
536540
}
537541

542+
protected virtual void BeforeWrite()
543+
{
544+
// Optionally override this function in a deriving class. Default
545+
// behavior is to take no action.
546+
}
547+
538548
protected virtual void OnWriteCompleted()
539549
{
540550
// Optionally override for deriving classes. Default behavior is to

com.playeveryware.eos/Runtime/Core/Config/ProductConfig.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ protected override void OnReadCompleted()
152152
// editor.
153153
#if UNITY_EDITOR
154154

155+
protected override void BeforeWrite()
156+
{
157+
// If there is one deployment, and one sandbox, then make sure they
158+
// are linked to each other.
159+
// But only do this if they have been newly added
160+
if (!_deploymentDefined && Environments.Deployments.Count ==1 && Environments.Sandboxes.Count == 1)
161+
{
162+
Environments.Deployments[0].Value.SandboxId = Environments.Sandboxes[0].Value;
163+
}
164+
}
165+
155166
protected override void OnWriteCompleted()
156167
{
157168
// If when the config was last read there was a deployment defined,

com.playeveryware.eos/Runtime/Core/EOS_SDK_Additions/EOSClientCredentials.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ public static bool IsEncryptionKeyValid(string encryptionKey)
8383
!s_invalidEncryptionKeyRegex.Match(encryptionKey).Success;
8484
}
8585

86+
public bool IsComplete
87+
{
88+
get
89+
{
90+
// TODO: Provide more comprehensive data validation (see Epic documentation for requirements)
91+
return !string.IsNullOrWhiteSpace(ClientId) && !string.IsNullOrWhiteSpace(ClientSecret);
92+
}
93+
}
94+
8695
/// <summary>
8796
/// Determines whether the encryption key for the credentials is valid.
8897
/// </summary>

0 commit comments

Comments
 (0)