Skip to content

Commit

Permalink
Merge pull request #49 from nowsprinting/fix/arg_error_to_warn
Browse files Browse the repository at this point in the history
Mod LogType `Warning` instead of `Error` when invalid argument
  • Loading branch information
nowsprinting committed Nov 19, 2023
2 parents 4527c2a + d2ef992 commit 103e027
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions RuntimeInternals/ScreenshotHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ private static string DefaultFilename(string callerMemberName)
{
if (superSize != 1 && stereoCaptureMode != ScreenCapture.StereoScreenCaptureMode.LeftEye)
{
Debug.LogError("superSize and stereoCaptureMode cannot be specified at the same time.");
Debug.LogWarning("superSize and stereoCaptureMode cannot be specified at the same time.");
yield break;
}

if (Thread.CurrentThread.ManagedThreadId != 1)
{
Debug.LogError("Must be called from the main thread.");
Debug.LogWarning("Must be called from the main thread.");
yield break;
// Note: This is not the case since it is a coroutine.
}
Expand Down
5 changes: 4 additions & 1 deletion Tests/Runtime/Attributes/TakeScreenshotAttributeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,16 @@ public void AttachWithSuperSize_SaveSuperSizeScreenshot()
}

[Test, Order(1)]
[Description("This test fails with stereo rendering settings.")]
public void AttachWithSuperSize_SaveSuperSizeScreenshot_ExistFile()
{
var path = Path.Combine(
_defaultOutputDirectory,
$"{nameof(AttachWithSuperSize_SaveSuperSizeScreenshot)}.png");
Assert.That(path, Does.Exist);
Assert.That(File.ReadAllBytes(path), Has.Length.GreaterThan(FileSizeThreshold2X));
// Note: This test fails with stereo rendering settings.
// See: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html
}

[Test, Order(0)]
Expand Down Expand Up @@ -265,7 +268,7 @@ public void AttachWithStereoCaptureMode_SaveStereoScreenshot_ExistFile()
Assert.That(path, Does.Exist);
// Is it a stereo screenshot? See for yourself! Be a witness!!
// Note: Require stereo rendering settings.
// See: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html
// See: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html
}

private class GizmoDemo : MonoBehaviour
Expand Down
4 changes: 2 additions & 2 deletions Tests/RuntimeInternals/ScreenshotHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public IEnumerator TakeScreenshot_SpecifySuperSizeAndStereoCaptureMode_NotWork()
yield return ScreenshotHelper.TakeScreenshot(
superSize: 2,
stereoCaptureMode: ScreenCapture.StereoScreenCaptureMode.BothEyes);
LogAssert.Expect(LogType.Error, "superSize and stereoCaptureMode cannot be specified at the same time.");
LogAssert.Expect(LogType.Warning, "superSize and stereoCaptureMode cannot be specified at the same time.");
}

[Test]
Expand All @@ -110,7 +110,7 @@ public async Task TakeScreenshot_FromAsyncTest()
var coroutineRunner = new GameObject().AddComponent<CoroutineRunner>();
await ScreenshotHelper.TakeScreenshot().ToUniTask(coroutineRunner);
// Note: UniTask is required to be used from the async test.
// And also needs coroutineRunner (any MonoBehaviour) because TakeScreenshot method uses WaitForEndOfFrame inside.
// And also needs CoroutineRunner (any MonoBehaviour) because TakeScreenshot method uses WaitForEndOfFrame inside.
// See more information: https://github.com/Cysharp/UniTask#ienumeratortounitask-limitation

Assert.That(path, Does.Exist);
Expand Down

0 comments on commit 103e027

Please sign in to comment.