champions-of-luneraria/Assets/Luneraria/Editor/Setup/LunePlayerBuild.cs
Martin Stickelbroeck 3ca38a8443 U2 Batch Asset Import
Alle 86 Modelle der Godot-Referenz laufen durch die Blender→FBX-Pipeline
(nach bestandenem Vertical Function Test); jede Einheit zeigt ihr eigenes
Modell.

- Exportmanifest aus den Godot-Manifesten (tools/blender/make_manifest.py):
  Units, Enemies, Props, Characters, Peoples, Buildings, Environment; die
  drei Vergleichs-GLBs als Aliase. Neu in der Pipeline: Tangenten berechnet
  Unity mit MikkTSpace, Generatoren laufen in einer temporären Kopie, die
  Grüne Kluft wird wie das GLB zusammengefasst, Texturen kommen mit.
  1.616 Blender- und 1.247 Unity-Prüfungen grün, zwei Exportläufe
  byteidentisch; Kontaktbögen je Gruppe.
- Einheitenbibliothek nach Godots AssetLibrary: 70 Einträge der
  Einheitengruppen, Figuren mit Skelett ersetzen das starre Modell ihrer ID.
  Starre Modelle werden zur Laufzeit je Material zusammengefasst; Controller
  werden an Ort und Stelle aktualisiert.
- Tests mit allen Modellen: EditMode 11/11, PlayMode 2/2. Vertical Function
  Test Seed 2 DCE95C96556F3A1A und Seed 9 ab Runde 21 7B8E43AEFC0D60C5,
  beide gleich dem Kern (Nachweise mit LUNE_EVIDENCE=u2a-batch; die Belege
  von U2C und U2D bleiben unverändert).
- macOS-Player mit allen Modellen: 158-160 fps in der Übersicht
  (116 Einheiten), 205-207 fps auf der Mid-Lane; Haupt- und Render-Thread
  etwa doppelt so lang wie mit dem Platzhalter, Present-Ausreißer kürzer.
- Befund iCloud Drive: Konfliktkopien ("Name 2.ext") im Build-Cache ließen
  den Build die Einheitenbibliothek mit altem Feldlayout schreiben; der
  Player meldete sharedassets0.assets als beschädigt. LunePlayerBuild
  entfernt solche Kopien vor dem Build und bricht ab, wenn während des
  Builds neue entstehen. Bereits committete Kopien: Controller-Duplikate und
  World/Generated 2.meta entfernt, drei U2D-Benchmarkläufe als -run1 bis
  -run3 benannt.
- Dokumentation: U2-WORLD (Batch-Import), PORT-STATUS (Entscheidungen:
  Modelle direkt in Git, Projektort außerhalb von iCloud Drive), PORT-QA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 19:10:35 +02:00

82 lines
4.3 KiB
C#

using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
namespace Luneraria.EditorTools
{
/// <summary>
/// Player builds (U2D). Only macOS is possible on this machine; Windows and Linux need the build
/// modules listed in docs/port/U1.5-UNITY.md. Output goes to Builds/ (ignored by git).
/// Unity -batchmode -projectPath . -executeMethod Luneraria.EditorTools.LunePlayerBuild.BuildMac -logFile -
/// </summary>
public static class LunePlayerBuild
{
static string Root { get { return Path.GetDirectoryName(Application.dataPath); } }
public static void BuildMac()
{
string path = Path.Combine(Root, "Builds/macOS/Luneraria.app");
foreach (string copy in ConflictCopies())
{
Debug.Log("LUNE_BUILD removing conflict copy " + copy);
File.Delete(copy);
}
// CPU and GPU frame timings for the benchmark (FrameTimingManager).
PlayerSettings.enableFrameTimingStats = true;
var options = new BuildPlayerOptions
{
scenes = new[] { LuneWorldBuilder.ScenePath },
locationPathName = path,
target = BuildTarget.StandaloneOSX,
options = BuildOptions.None,
};
BuildReport report = BuildPipeline.BuildPlayer(options);
Debug.Log(string.Format("LUNE_BUILD {0}: {1}, {2:0.0} MB, {3:0.0} s", report.summary.result, path, report.summary.totalSize / 1048576.0, report.summary.totalTime.TotalSeconds));
foreach (PackedAssets packed in report.packedAssets)
{
ulong total = 0;
foreach (PackedAssetInfo info in packed.contents)
total += info.packedSize;
Debug.Log(string.Format("LUNE_BUILD file {0}: {1} objects, {2:0.0} MB", packed.shortPath, packed.contents.Length, total / 1048576.0));
foreach (PackedAssetInfo info in packed.contents.OrderByDescending(c => c.packedSize).Take(5))
Debug.Log(string.Format("LUNE_BUILD {0:0.00} MB {1} {2}", info.packedSize / 1048576.0, info.type, info.sourceAssetPath));
Directory.CreateDirectory(Path.Combine(Root, "tools/out"));
File.WriteAllLines(Path.Combine(Root, "tools/out/build-" + packed.shortPath + ".txt"),
packed.contents.Select(c => c.packedSize + " " + c.type + " " + c.sourceAssetPath));
}
string[] appeared = ConflictCopies();
foreach (string copy in appeared)
Debug.LogError("LUNE_BUILD conflict copy appeared during the build: " + copy);
bool trusted = appeared.Length == 0;
if (!trusted)
Debug.LogError("LUNE_BUILD the build may carry stale script layouts; build again");
EditorApplication.Exit(report.summary.result == BuildResult.Succeeded && trusted ? 0 : 1);
}
/// <summary>
/// Copies a sync service (iCloud Drive) keeps of a replaced file, named "name 2.ext". In the
/// build cache a copy of an old player assembly enters the build's type database before the
/// current one, scripted objects are then written with the old field layout and the player
/// reports sharedassets0.assets as corrupted. Only build caches are searched; a copy is one
/// whose original (without " 2") exists next to it.
/// </summary>
static string[] ConflictCopies()
{
var copy = new Regex(@"^(.+) \d+(\.[^.]+)?$");
return new[] { "Library/Bee", "Library/BuildPlayerData", "Library/PlayerDataCache" }
.Select(folder => Path.Combine(Root, folder))
.Where(Directory.Exists)
.SelectMany(folder => Directory.GetFiles(folder, "* *", SearchOption.AllDirectories))
.Where(file =>
{
Match match = copy.Match(Path.GetFileName(file));
return match.Success && File.Exists(Path.Combine(Path.GetDirectoryName(file), match.Groups[1].Value + match.Groups[2].Value));
})
.OrderBy(file => file, System.StringComparer.Ordinal)
.ToArray();
}
}
}