BuildPipeline.BuildPlayer() missing splash screen tools background.

I am currently working on a build pipeline to use during project development, and have been reading and utilizing the BuildPipeline UnityEditor class, together with related structs (such as BuildPlayerOptions) to attempt and develop an editor menu option that builds all of our platforms in a single click, instead of having to manually wait for each compile to change the platform to build each individual player.

Since most of the code I’ve built so far is designed on top of the example in the Scripting API, the task has been mostly successful, with all the players building as expected.

As our team uses Unity Personal, we utilize Unity’s built-in splash screen tools in order to design our splash screens. However, when creating the players using the BuildPipeline.BuildPlayer() function, the player will ship with the splash screen’s background missing from all of the builds. This behaviour doesn’t happen when manually building a player with the ‘Build Settings’ or using ‘Build & Run’ where the splash screen background shows as intended.

I have not been able to find the reason as to why this happens, and have even tried to manually feed the splash screen Sprite to the PlayerSettings.SplashScreen.background by code but without any diference in results.

To give a better understanding of the situation, I have attached example screenshots of what’s currently happening, as well as the code being used, bellow.

Splash Screen Missing using ‘BuildPipeline.BuildPlayer()’:
[115803-2018-04-27-15h-06m-02s.png*_|115803]

Splash Screen displaying on a build manually created from ‘Build Settings’:
[115804-2018-04-27-15h-09m-19s.png*_|115804]

Splash Screen options in the Player Settings:
![alt text][3]

Code being used:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;

public class BuildTools : MonoBehaviour
{
    /// <summary>
    /// Queues up all the build players to be built.
    /// </summary>
    [MenuItem("Build/Build All Players")]
    public static void BuildAllPlayers()
    {
        BuildPlatform(BuildTarget.StandaloneWindows, "-windows-32");
        BuildPlatform(BuildTarget.StandaloneWindows64, "-windows-64");
        BuildPlatform(BuildTarget.StandaloneOSX, "-mac-osx");
        BuildPlatform(BuildTarget.StandaloneLinuxUniversal, "-linux");
    }

    /// <summary>
    /// Builds the target to this platform.
    /// </summary>
    public static void BuildPlatform(BuildTarget target, string platformId)
    {
        // Sets up the directory where the build will be placed at. Stored for extra uses.
        string buildDirectory = Application.dataPath;
        buildDirectory = buildDirectory.Substring(0, buildDirectory.Length - 6); // Removes 'Assets/' from the path, so builds are placed on the project folder instead.
        buildDirectory += "Builds" + Path.DirectorySeparatorChar; // Appends the Build folder.
        buildDirectory += Application.productName.ToLower() + platformId + Path.DirectorySeparatorChar; // Appends the platform folder.

        // Sets up the remainder of the build directory.
        string buildPath = buildDirectory + Application.productName + Path.DirectorySeparatorChar; // Appends the game directory.
        buildPath += Application.productName + ".exe"; // Apends the actual .exe path.

        // Sets up player options.
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions
        {
            target = target,
            scenes = GetScenes(),
            locationPathName = buildPath,
            options = BuildOptions.None,
        };

        // Outputs the build, checking for each errors.
        string error = BuildPipeline.BuildPlayer(buildPlayerOptions);
        if (error == "")
            Debug.LogWarning("Sucessfully Built " + platformId + " at " + buildDirectory + ".");
        else
            Debug.LogError("Error Building " + platformId + ".");
    }

    /// <summary>
    /// Gets the scenes from the build settings to be appended to the build options.
    /// </summary>
    public static string[] GetScenes()
    {
        string[] scenes = new string[EditorBuildSettings.scenes.Length];
        for (int i = 0; i < scenes.Length; i++)
        {
            scenes _= EditorBuildSettings.scenes*.path;*_

}
return scenes;
}
}

Anyone has any idea of what could possibly be creating this behaviour or if there is any other code I should add that can possibly solve the issue?

Thanks!
_*
_*
_*[3]: https://i.imgur.com/ZVq6KGW.png*_

Hi,

I was facing the same issue still with 2018.3. Turns out the -nographics as an option on the command line was causing the issue. getting rid of this parameter fixed the issue.