Search Unity

Compiler Error on Unity Batch Mode

Discussion in 'Linux' started by gamefox87, Nov 7, 2019.

  1. gamefox87

    gamefox87

    Joined:
    Aug 19, 2016
    Posts:
    64
    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:
    Code (CSharp):
    1. using UnityEditor;
    2. using System.IO;
    3. using UnityEngine;
    4. using System.Linq;
    5. /// <summary>
    6. /// Manages the creation of asset bundles for use on game
    7. /// </summary>
    8. public class Editor
    9. {
    10.     [MenuItem("Assets/Build AssetBundles")]
    11.     public static void BuildAllAssetBundles()
    12.     {
    13.         ConfigureArtsBundles();
    14.         string BundlesPath = "Assets\\Generated"; // Where the bundles will be outputed to
    15.         BuildPipeline.BuildAssetBundles(BundlesPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
    16.         RenameManifest(BundlesPath);
    17.     }
    18.  
    19.     private static void ConfigureArtsBundles()
    20.     {
    21.         string artsPath = Path.Combine("Assets", "Update", "Bundles", "Arts");
    22.         string currentPath;
    23.         TextureImporterSettings settings = new TextureImporterSettings();
    24.         TextureImporter template = ((TextureImporter)AssetImporter.GetAtPath(Path.Combine("Assets", "Update", "Atlas", "Interface", "Missing.jpg")));
    25.         template.ReadTextureSettings(settings);
    26.         foreach (DirectoryInfo artDir in new DirectoryInfo(artsPath).GetDirectories().OrderBy((DirectoryInfo d) => byte.Parse(d.Name)))
    27.         {
    28.             if (!int.TryParse(artDir.Name, out int dirId) || dirId < 0)
    29.                 continue;
    30.             currentPath = Path.Combine(artsPath, artDir.Name);
    31.             AssetImporter.GetAtPath(currentPath).SetAssetBundleNameAndVariant($"arts{artDir.Name}", "");
    32.             foreach (FileInfo art in artDir.GetFiles("*.jpg"))
    33.             {
    34.                 TextureImporter ti = ((TextureImporter)AssetImporter.GetAtPath(Path.Combine(currentPath, art.Name)));
    35.                 ti.SetTextureSettings(settings);
    36.                 if (ti.compressionQuality != template.compressionQuality || ti.crunchedCompression != template.crunchedCompression || ti.maxTextureSize != template.maxTextureSize)
    37.                 {
    38.                     ti.compressionQuality = template.compressionQuality;
    39.                     ti.crunchedCompression = template.crunchedCompression;
    40.                     ti.maxTextureSize = template.maxTextureSize;
    41.                     ti.SaveAndReimport();
    42.                 }
    43.             }
    44.         }        
    45.     }
    46.  
    47.     private static void RenameManifest(string BundlesPath)
    48.     {
    49.         string gameData = Path.Combine(BundlesPath, BundlesPath.Substring(BundlesPath.LastIndexOf('\\') + 1));
    50.         string gameDataManifest = Path.Combine(BundlesPath, string.Concat(BundlesPath.Substring(BundlesPath.LastIndexOf('\\') + 1), ".manifest"));
    51.         string realGameData = Path.Combine(BundlesPath, "GameData");
    52.         string realGameDataManifest = Path.Combine(BundlesPath, "GameData.manifest");
    53.         if (File.Exists(realGameData))
    54.             File.Delete(realGameData);
    55.         File.Move(gameData, realGameData);
    56.         if (File.Exists(realGameDataManifest))
    57.             File.Delete(realGameDataManifest);
    58.         File.Move(gameDataManifest, realGameDataManifest);
    59.     }
    60. }
    61.  
    I'm using Unity 2019.2.11f1 on Ubuntu
     
  2. KevinWelton

    KevinWelton

    Joined:
    Jul 26, 2018
    Posts:
    239
    Hi @gamefox87. Can you attach your editor.log file from ~/.config/unity3d for me?

    Thanks!
     
  3. gamefox87

    gamefox87

    Joined:
    Aug 19, 2016
    Posts:
    64
  4. KevinWelton

    KevinWelton

    Joined:
    Jul 26, 2018
    Posts:
    239
    I get a 404 when following the link.
     
  5. gamefox87

    gamefox87

    Joined:
    Aug 19, 2016
    Posts:
    64
    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.
     
    KevinWelton likes this.