Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Command line builds are not rendering graphics right, building from Editor UI renders correct.

Discussion in 'General Graphics' started by spycarrot, Jun 6, 2022.

  1. spycarrot

    spycarrot

    Joined:
    Feb 20, 2015
    Posts:
    8
    I'm working on a simple multiplayer project. I have a build system that I use to build the game client and server. I've made it script I can call it from the menu. I wanted to automate the build in a CI/CD pipeline and everything was going smoothly until I discovered the client wasn't rendering as expected. However my client and server function as expected, aside from this rendering issue. I can get around this by building from the UI, but I want to automate this process and I am not sure what I am doing wrong.

    I'm currently using Unity 2021.1.3f1.

    When I run my build script (below) from this menu in the editor, I get the expected result (yellowish walls and a white ground):


    When I run the same script from powershell, the materials do not render correctly (everything is brownish):

    & "C:\Program Files\Unity\Hub\Editor\2021.1.3f1\Editor\Unity.exe" -projectPath ".\MyXXXUnityProject\" -executeMethod BuildSystem.BuildClientWindows



    Code (CSharp):
    1.  public class BuildSystem
    2. {
    3.     [MenuItem("Build/BuildAll")]
    4.     public static void BuildAll()
    5.     {
    6.         BuildServerWindows();
    7.         BuildClientWindows();
    8.     }
    9.  
    10.     [MenuItem("Build/BuildServer")]
    11.     public static void BuildServerWindows()
    12.     {
    13.         BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    14.         buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
    15.         buildPlayerOptions.locationPathName = "Builds/Server/Windows/Server.exe";
    16.         buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
    17.         buildPlayerOptions.options = BuildOptions.EnableHeadlessMode;
    18.         BuildPipeline.BuildPlayer(buildPlayerOptions);
    19.     }
    20.  
    21.     [MenuItem("Build/BuildClient")]
    22.     public static void BuildClientWindows()
    23.     {
    24.         BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    25.         buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
    26.         buildPlayerOptions.locationPathName = "Builds/Client/Windows/Client.exe";
    27.         buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
    28.         BuildPipeline.BuildPlayer(buildPlayerOptions);
    29.     }
    30. }

    Digging more I found an error that occurs when the build happens from command line but not when I execute through the UI manually. The error seems to have to do with visual scripting, so I am not 100% certain it is related. Any advice would be awesome! I really want to get builds working command line.


    NullReferenceException: Object reference not set to an instance of an object
    Unity.VisualScripting.BoltCore.get_Paths () (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Plugin/BoltCore.cs:41)
    Unity.VisualScripting.AotPreBuilder.get_linkerPath () (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:28)
    Unity.VisualScripting.AotPreBuilder.DeleteAotStubs () (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:85)
    Unity.VisualScripting.AotPreBuilder.OnPostProcessBuild (UnityEditor.BuildTarget target, System.String pathToBuiltProject) (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:40)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    UnityEditor.Build.BuildPipelineInterfaces+AttributeCallbackWrapper.OnPostprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at <1798d6bccd2b44b2854be2fbcc2463b3>:0)
    UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass17_0.<OnBuildPostProcess>b__1 (UnityEditor.Build.IPostprocessBuildWithReport bpp) (at <1798d6bccd2b44b2854be2fbcc2463b3>:0)
    UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) (at <1798d6bccd2b44b2854be2fbcc2463b3>:0)
    UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
    BuildSystem:BuildClientWindows() (at Assets/Editor/BuildSystem.cs:67)
    BuildSystem:BuildAll() (at Assets/Editor/BuildSystem.cs:24)
     
  2. kburgin1

    kburgin1

    Joined:
    Jul 10, 2019
    Posts:
    10
    We also have this issue, did you find a solution?
     
  3. spycarrot

    spycarrot

    Joined:
    Feb 20, 2015
    Posts:
    8
    I have not yet, but I plan to post the solution once I have it. Can you please let me know if you figure it out?
     
  4. kburgin1

    kburgin1

    Joined:
    Jul 10, 2019
    Posts:
    10
    We solved this yesterday by adding a default lighting settings object to the scene lighting settings (Window->Rendering->Lighting). We had multiple scenes and one was missing a settings object. It seems if the settings field is left Missing, then behaviour is undefined and must be treated differently in different contexts. Just by specifying defaults, it then seems consistent between builds.