Rebuild the game as a single code-driven scene with a package-folder pack source

- One empty scene; App builds the canvas, safe-area layout and a shared 5x6
  Grid in code. Pages (Intro, Main, Choose, Play, Account, Settings) replace
  5 scenes, 5 prefabs and the per-cell spawner/display components.
- Packs: the game reads Rhyculator/package/ (with All files access) or the
  app folder, like a plugged-in USB stick. Zips stay where they are and are
  extracted to a cache keyed by name/size/mtime; folders are read directly.
  Scans run every second on a background thread. Old songs/ imports and inbox
  zips are migrated automatically.
- Download packs by 8-char code from the new pack website, or via
  rhyculator://pack/<code> links; opened/shared zips go into the package folder.
- Play: pause/resume/retry, auto-pause on background, combo and progress bar;
  judging and scoring unchanged. Choose page fits 9:16 screens; empty state,
  pack delete. Android back key handled everywhere.
- Slimming: removed TextMesh Pro, unused 2D/Timeline/VisualScripting/etc.
  packages and modules, scene template, unused sprites; menu theme wav (20MB)
  -> ogg (2.3MB). Build profile replaced by explicit settings in BuildAndroid.
- Tests: PackLibrary/PackReader/migration/serializer tests (39 passing).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
SahikandClaude Opus 5.5 committed 2026-10-24 14:18:54 +08:00
1 parent 6d5f66ac6a
commit ddd5fdc28b
295 files changed
+3854 -82126

No files matched your search

+55 -16
View File
@@ -1,39 +1,78 @@
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Profile;
using UnityEditor.Build.Reporting;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Rendering.Universal;
// 指令列打包:
// Unity.exe -batchmode -quit -projectPath <path> -executeMethod BuildAndroid.Build -logFile build.log
// 指令列打包(產出 Build/Rhyculator.apk,並複製一份到專案根目錄 Rhyculator.apk):
// Unity.exe -batchmode -quit -projectPath <path> -buildTarget Android -executeMethod BuildAndroid.Build -logFile build.log
// 加上 -development 打包 Development Build(可看 log、連 Profiler)
public static class BuildAndroid
{
public const string OutputPath = "Build/Lunchpad.apk";
public const string ScenePath = "Assets/Scenes/Main.unity";
public const string OutputPath = "Build/Rhyculator.apk";
public const string SideloadPath = "Rhyculator.apk";
public const string ProfilePath = "Assets/Settings/Build Profiles/Android™.asset";
[MenuItem("Build/Android APK")]
public static void Build()
{
// 使用專案的 Android Build Profile(場景清單與 Player Settings 都在裡面)
var profile = AssetDatabase.LoadAssetAtPath<BuildProfile>(ProfilePath);
BuildProfile.SetActiveBuildProfile(profile);
EnsureScene();
ApplyPlayerSettings();
// 注意:本地伺服器走 http,Profile 內的 insecureHttpOption 已設為 2 (AlwaysAllowed)
// 正式上線改回 https 後,記得在 Build Profile 的 Player Settings 改回 Not Allowed
var report = BuildPipeline.BuildPlayer(new BuildPlayerWithProfileOptions
bool dev = System.Environment.GetCommandLineArgs().Contains("-development");
var report = BuildPipeline.BuildPlayer(new BuildPlayerOptions
{
buildProfile = profile,
scenes = new[] { ScenePath },
target = BuildTarget.Android,
targetGroup = BuildTargetGroup.Android,
locationPathName = OutputPath,
options = BuildOptions.Development
options = dev ? BuildOptions.Development : BuildOptions.None,
});
// 另存一份到專案根目錄,方便直接複製到手機安裝
if (report.summary.result == BuildResult.Succeeded)
System.IO.File.Copy(OutputPath, SideloadPath, true);
File.Copy(OutputPath, SideloadPath, true);
Debug.Log($"[BuildAndroid] {report.summary.result}, {report.summary.totalSize / 1024 / 1024} MB, errors={report.summary.totalErrors}");
if (Application.isBatchMode)
EditorApplication.Exit(report.summary.result == BuildResult.Succeeded ? 0 : 1);
}
// 整個遊戲只有一個場景:一台清成黑色的攝影機,其他全部由 App 在執行時建立
[MenuItem("Build/Create Main Scene")]
public static void EnsureScene()
{
if (!File.Exists(ScenePath))
{
Directory.CreateDirectory(Path.GetDirectoryName(ScenePath));
var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
var cam = new GameObject("Main Camera", typeof(Camera)).GetComponent<Camera>();
cam.tag = "MainCamera";
cam.clearFlags = CameraClearFlags.SolidColor;
cam.backgroundColor = Color.black;
cam.orthographic = true;
cam.cullingMask = 0;
cam.gameObject.AddComponent<UniversalAdditionalCameraData>();
EditorSceneManager.SaveScene(scene, ScenePath);
}
EditorBuildSettings.scenes = new[] { new EditorBuildSettingsScene(ScenePath, true) };
}
static void ApplyPlayerSettings()
{
PlayerSettings.productName = "Rhyculator";
PlayerSettings.bundleVersion = "3.0.0";
// 沿用舊的套件名,已安裝的玩家可以直接覆蓋更新(登入狀態、設定都保留)
PlayerSettings.SetApplicationIdentifier(UnityEditor.Build.NamedBuildTarget.Android, "com.DefaultCompany.Lunchpad");
PlayerSettings.SetScriptingBackend(UnityEditor.Build.NamedBuildTarget.Android, ScriptingImplementation.IL2CPP);
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel25;
PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait;
PlayerSettings.SetManagedStrippingLevel(UnityEditor.Build.NamedBuildTarget.Android, ManagedStrippingLevel.Low);
PlayerSettings.stripEngineCode = true;
// 本地伺服器走 http;正式上線(ServerConfig.UseLocal = false)只允許 https
PlayerSettings.insecureHttpOption = ServerConfig.UseLocal ? InsecureHttpOption.AlwaysAllowed : InsecureHttpOption.NotAllowed;
AssetDatabase.SaveAssets();
}
}