@@ -102,6 +102,14 @@ public class ProductConfig : Config
102102 "exist within the Epic Dev Portal." , 1 ) ]
103103 public ProductionEnvironments Environments = new ( ) ;
104104
105+ /// <summary>
106+ /// This field member is used to determine when deployments are first
107+ /// defined by the user. This determination is used to trigger the
108+ /// process of setting the default deployment for the platforms.
109+ /// </summary>
110+ [ JsonIgnore ]
111+ private bool _deploymentDefined ;
112+
105113 static ProductConfig ( )
106114 {
107115 RegisterFactory ( ( ) => new ProductConfig ( ) ) ;
@@ -114,6 +122,56 @@ protected override bool NeedsMigration()
114122
115123 protected ProductConfig ( ) : base ( "eos_product_config.json" ) { }
116124
125+ protected override void OnReadCompleted ( )
126+ {
127+ // This tracks whether there is a single deployment defined.
128+ _deploymentDefined = Environments . IsDeploymentDefined ;
129+ }
130+
131+ // This compile conditional is here because the OnWriteCompleted method
132+ // is only defined in the editor - so it can only be overriden if in the
133+ // editor.
134+ #if UNITY_EDITOR
135+
136+ protected override void OnWriteCompleted ( )
137+ {
138+ // If when the config was last read there was a deployment defined,
139+ // or there is not now one defined - then there is no need to try
140+ // and set the deployment values for each platform config.
141+ if ( _deploymentDefined || ! Environments . IsDeploymentDefined )
142+ {
143+ return ;
144+ }
145+
146+ // Select the first defined deployment as the deployment to set
147+ // platform configs to use.
148+ Named < Deployment > deploymentToSetPlatformsTo = Environments . Deployments [ 0 ] ;
149+
150+ // For each platform for which configuration can be done
151+ foreach ( var platform in PlatformManager . ConfigurablePlatforms )
152+ {
153+ // If the PlatformConfig could not be retrieved, continue to the
154+ // next.
155+ if ( ! PlatformManager . TryGetConfig ( platform , out PlatformConfig config ) )
156+ {
157+ continue ;
158+ }
159+
160+ // Set the deployment.
161+ config . deployment = deploymentToSetPlatformsTo . Value ;
162+
163+ // Tell the user
164+ Debug . Log ( $ "Deployment for platform " +
165+ $ "\" { config . Platform } \" has been defaulted to " +
166+ $ "{ deploymentToSetPlatformsTo } .") ;
167+
168+ // Save the config
169+ config . Write ( ) ;
170+ }
171+ }
172+
173+ #endif
174+
117175 #region Functionality to migrate from old configuration to new
118176
119177 internal class PreviousEOSConfig : Config
0 commit comments