Skip to content

Commit

Permalink
Also call DetectUnityVersion when in UnityTasks.UnityRunTests
Browse files Browse the repository at this point in the history
The generic PreProcess method on line 111 also handles Unity runs that don't directly relate to a project (e.g. license activation). However, for the tasks which deal with projects, we want them to auto-detect the Unity editor version from the project. Previously this was only implemented when starting the general UnityTasks.Unity method, but now it's also used when running tests.
  • Loading branch information
Christopher Yarbrough committed Sep 23, 2024
1 parent bb3b6a0 commit f35a5e0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions source/Nuke.Common/Tools/Unity/UnityTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,27 @@ private static string GetProgramFiles()
}

private static void PreProcess(ref UnitySettings unitySettings)
{
var projectSettings = (UnityProjectSettings)unitySettings;
PreProcessWithAutoDetect(ref projectSettings);
}

private static void PreProcess(ref UnityRunTestsSettings unitySettings)
{
var projectSettings = (UnityProjectSettings)unitySettings;
PreProcessWithAutoDetect(ref projectSettings);
}

private static void PreProcessWithAutoDetect(ref UnityProjectSettings unitySettings)
{
if (unitySettings.ProjectPath == null)
Log.Warning("ProjectPath is not set, using last opened/built project");

DetectUnityVersion(ref unitySettings);
PreProcess<UnitySettings>(ref unitySettings);
PreProcess(ref unitySettings);
}

private static void DetectUnityVersion(ref UnitySettings unitySettings)
private static void DetectUnityVersion(ref UnityProjectSettings unitySettings)
{
if (unitySettings.HubVersion != null ||
unitySettings.ProjectPath == null)
Expand Down

0 comments on commit f35a5e0

Please sign in to comment.