Saltar al contenido principal

Check that your world compiles for upload

Before a world upload, UdonSharp compiles every program again, for upload, and a program that compiles in the Editor can fail there. Check it in an Edit Mode test with UdonSharpUploadCompile, so a failure shows up before you upload.

Steps​

  1. In your Tests/EditMode folder, create UploadCompileTests.cs:

    using NUnit.Framework;
    using Tsvrc.UdonTestKit;

    public class UploadCompileTests
    {
    [Test]
    public void UploadCompile_EveryProgram_LogsNoErrors()
    {
    Assert.That(UdonSharpUploadCompile.Run(), Is.Empty);
    }
    }
  2. Run it from the EditMode tab of the Test Runner. It compiles every UdonSharp program in the project for the Editor, for upload, and for the Editor again, so it takes longer than most tests.

When a program fails, the assertion fails and lists the errors UdonSharp logged.

What makes the compile fail​

The compile for upload reads only player assemblies and leaves out the code inside #if UNITY_EDITOR. A program asset whose script is in a tests-only assembly makes it compile no program at all, and code that compiles only together with code inside #if UNITY_EDITOR fails it. What the kit works around explains both.