Detect if Unity is building/compiling the project/scene

My team has some licensed software that we would like to include in a Unity project. We’ve developed license verification code that has worked for us for a few years on mobile. When developing with our software, we would like to check the license to verify that it is valid, but when the Unity app is already built and running for the consumer, we would like to bypass the license verification.

Can we:

  • Detect if Unity is currently building or compiling our project?
  • If true, verify the license
  • If false, bypass the license verification

If the license verification fails we want to throw an exception to alert the developer.

A glance at the documentation reveals these two: BuildPipeline.isBuildingPlayer, and EditorApplication.isCompiling.