We are using a C# script in the Unity editor to execute some steps of build pipeline, like building addessables, setting up scripting parameters or build options and building player itself. It is implemented as static void method as described here. I’m trying to add another step to that sequence, and it will upload freshly built addressable bundles to the CCD service.
While this step works fine in editor started as GUI process, it throws an exception when run from CLI in batch mode, which is essential for CI builds:
<b>[UploadToUnityCloudStep]</b>: Cloud Services must enabled and connected to a Unity Cloud Project.
This exception pops up from this line:
await CcdManagement.Instance.CreateOrUpdateEntryByPathAsync(entryByPathOptions, entryOptions);
This method contains a following block of code:
if (string.IsNullOrEmpty(CcdManagement.projectid))
{
throw new CcdManagementException(CommonErrorCodes.InvalidRequest, SERVICES_ERROR_MSG);
}
So situation looks like that there is no cloud project ID set at the time of the execution of this block of code.
I tried to run the following method in Unity, starting it from terminal:
public static async void Test()
{
while (string.IsNullOrEmpty(CloudProjectSettings.projectId))
{
Debug.Log("Awaiting Cloud Project Binding");
await UniTask.Yield();
}
Debug.Log($"Cloud Project Id: {CloudProjectSettings.projectId}");
EditorApplication.Exit(0);
}
If i execute it without the -batchmode parameter, it starts an editor in the GUI mode as usual, Unity post some logs from the while block to console and then logs a synced project id. If i execute the same command in batch mode, the script execution never leaves the while block and logs “Awaiting…” endlessly.
While comparing editor logs of both cases I noticed that the GUI process has some lines, and the batch mode process doesn’t:
[collab-accelerator] discovery started due to a new cloud project binding
UPID Received 'xxxxxxxxxxxxxxxxxxxxxxxxxx'.
I guess something triggers Unity Services project sync in GUI, but it doesn’t happen in batch mode. Everything connected to such sync which I managed to find leads to the UnityConnect class, and it is internal to UnityEditor.CoreModule.dll
So what should I do to refresh the project connection to Unity Services in batch mode? Am I missing something here?
Tried everything above with following configurations:
- Unity 2021.3.5f1, 2021.3.18f1
- Addressables 1.21.2
- CCD Management 2.2.2
- Services Core 1.7.1