Compiler Error on Unity Batch Mode

Hi guys,

I’m trying to run Unity in batch mode on Linux to automate building of asset bundles. Here is my output: https://gitlab.com/duelists-unite/unitydummy/-/jobs/344033432

Below is the part where you see that it says “Scripts have compiler errors.”

Now I can build without errors just fine running the Unity Editor manually on Windows.

My Editor.cs script is here:

using UnityEditor;
using System.IO;
using UnityEngine;
using System.Linq;
/// <summary>
/// Manages the creation of asset bundles for use on game
/// </summary>
public class Editor
{
    [MenuItem("Assets/Build AssetBundles")]
    public static void BuildAllAssetBundles()
    {
        ConfigureArtsBundles();
        string BundlesPath = "Assets\\Generated"; // Where the bundles will be outputed to
        BuildPipeline.BuildAssetBundles(BundlesPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
        RenameManifest(BundlesPath);
    }

    private static void ConfigureArtsBundles()
    {
        string artsPath = Path.Combine("Assets", "Update", "Bundles", "Arts");
        string currentPath;
        TextureImporterSettings settings = new TextureImporterSettings();
        TextureImporter template = ((TextureImporter)AssetImporter.GetAtPath(Path.Combine("Assets", "Update", "Atlas", "Interface", "Missing.jpg")));
        template.ReadTextureSettings(settings);
        foreach (DirectoryInfo artDir in new DirectoryInfo(artsPath).GetDirectories().OrderBy((DirectoryInfo d) => byte.Parse(d.Name)))
        {
            if (!int.TryParse(artDir.Name, out int dirId) || dirId < 0)
                continue;
            currentPath = Path.Combine(artsPath, artDir.Name);
            AssetImporter.GetAtPath(currentPath).SetAssetBundleNameAndVariant($"arts{artDir.Name}", "");
            foreach (FileInfo art in artDir.GetFiles("*.jpg"))
            {
                TextureImporter ti = ((TextureImporter)AssetImporter.GetAtPath(Path.Combine(currentPath, art.Name)));
                ti.SetTextureSettings(settings);
                if (ti.compressionQuality != template.compressionQuality || ti.crunchedCompression != template.crunchedCompression || ti.maxTextureSize != template.maxTextureSize)
                {
                    ti.compressionQuality = template.compressionQuality;
                    ti.crunchedCompression = template.crunchedCompression;
                    ti.maxTextureSize = template.maxTextureSize;
                    ti.SaveAndReimport();
                }
            }
        }         
    }

    private static void RenameManifest(string BundlesPath)
    {
        string gameData = Path.Combine(BundlesPath, BundlesPath.Substring(BundlesPath.LastIndexOf('\\') + 1));
        string gameDataManifest = Path.Combine(BundlesPath, string.Concat(BundlesPath.Substring(BundlesPath.LastIndexOf('\\') + 1), ".manifest"));
        string realGameData = Path.Combine(BundlesPath, "GameData");
        string realGameDataManifest = Path.Combine(BundlesPath, "GameData.manifest");
        if (File.Exists(realGameData))
            File.Delete(realGameData);
        File.Move(gameData, realGameData);
        if (File.Exists(realGameDataManifest))
            File.Delete(realGameDataManifest);
        File.Move(gameDataManifest, realGameDataManifest);
    }
}

I’m using Unity 2019.2.11f1 on Ubuntu

Hi @gamefox87 . Can you attach your editor.log file from ~/.config/unity3d for me?

Thanks!

Thanks for responding. I’m running this through gitlab. Is the log not this output? https://gitlab.com/duelists-unite/unitydummy/-/jobs/344777842

If not, I’ll have to run it on Linux locally and then get that file to you.

I get a 404 when following the link.

It seems we have figured it out. I created a new dummy project on Unity on Ubuntu. Then I re-packaged the bundles and it worked without errors. We got errors before because the previous project was made on Unity for Windows. Thank you.

1 Like