SOLVED - 'PlayerSettings' does not exist in the current context

Hello, I’m trying to run a Pre-Export script in Unity Cloud Build that modifies PlayerSettings. The guidance I’ve found online says to

  1. Wrap the function with pre-compiler directive #if UNITY_CLOUD_BUILD
  2. Place your script in an Editor folder

I’ve done exactly that, but still get this error

8: [2022-12-03T07:56:04Z - Unity] Assets\Editor\CloudBuildHelper.cs(8,5): error CS0103: The name 'PlayerSettings' does not exist in the current context

My CloudBuildHelper.cs file looks like this:

using UnityEngine;

public class CloudBuildHelper : MonoBehaviour {
#if UNITY_CLOUD_BUILD
  public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest) {
    var buildNumber = "unknown";
    manifest.TryGetValue("buildNumber", out buildNumber);
    PlayerSettings.bundleVersion = string.Format("0.0.{0}", buildNumber);
  }
#endif
}

I’m using Unity 2021.3.14f1 in Cloud Build.

Does anyone have any ideas on what it could be?

Ignore me - forgot the line using UnityEditor;, d’oh!