Search Unity

Compile Error - PlayerSettings does not exist in the namespace UnityEditor

Discussion in 'Unity Build Automation' started by VirtualMedicine, Jul 25, 2018.

  1. VirtualMedicine

    VirtualMedicine

    Joined:
    Jun 26, 2017
    Posts:
    6
    Hello,
    I have one VR project and I want to build it for different VR platforms (OpenVr, Oculus). So I created multiple build targets and set them PreExport methods.

    Code (CSharp):
    1.  
    2. #if UNITY_CLOUD_BUILD
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. public class CloudBuildHelper {
    7.     public static void PreExportStandaloneVive() {
    8.         PlayerSettings.virtualRealitySupported = true;
    9.         PlayerSettings.SetVirtualRealitySDKs(BuildTargetGroup.Standalone, new[] {"OpenVr"});
    10.     }
    11.  
    12.     public static void PreExportStandaloneOculus() {
    13.         PlayerSettings.virtualRealitySupported = true;
    14.         PlayerSettings.SetVirtualRealitySDKs(BuildTargetGroup.Standalone, new[] {"Oculus"});
    15.     }
    16. #endif
    17.  

    When I run unity cloud build I get compile errors:
    9165: [Unity] -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll
    9166: [Unity] Compilation failed: 46 error(s), 1 warnings
    9167: [Unity] Assets/Scripts/CloudBuild/CloudBuildHelper.cs(8,21): error CS0234: The type or namespace name `PlayerSettings' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?
    9168: [Unity] Assets/Scripts/CloudBuild/CloudBuildHelper.cs(9,21): error CS0234: The type or namespace name `PlayerSettings' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?
    9169: [Unity] Assets/Scripts/CloudBuild/CloudBuildHelper.cs(14,21): error CS0234: The type or namespace name `PlayerSettings' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?
    9170: [Unity] Assets/Scripts/CloudBuild/CloudBuildHelper.cs(19,21): error CS0234: The type or namespace name `PlayerSettings' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?
    .........................
    9771: ! Unity player export failed!
    9772: ! build of 'standalonevive_develop_notauto_2018-1' failed. compile failed
    ..................

    Currently using Unity 2018.1.0f2
    If the project doesn't contain class CloudBuildHelper and build target doesnt have preexport method, build will be successful, but XR settings are not set properly - VR doesnt work.
     
    Enkendu1 likes this.
  2. VirtualMedicine

    VirtualMedicine

    Joined:
    Jun 26, 2017
    Posts:
    6
    I've received a response from Unity Support.
    All I needed to do was move my CloudBuildHelper class to Editor folder.
    Now it all works. :)
     
  3. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    You still have to do that as of Jan 10, 2020 in Unity 2019.2...
     
  4. djlastnight

    djlastnight

    Joined:
    Dec 10, 2020
    Posts:
    2
    Thanks, helps a lot!