webzepetoku commited on
Commit
eda3d3a
·
verified ·
1 Parent(s): 8f03243

Update UnityProject/Assets/Editor/TestBuilder.cs

Browse files
UnityProject/Assets/Editor/TestBuilder.cs CHANGED
@@ -15,15 +15,14 @@ public class TestBuilder
15
  {
16
  try
17
  {
18
- Debug.Log("🛠️ [UNITY] Memulai Export Paket Lengkap (Semua Platform)...");
19
 
20
  if (Directory.Exists(FINAL_EXPORT_DIR)) Directory.Delete(FINAL_EXPORT_DIR, true);
21
  Directory.CreateDirectory(FINAL_EXPORT_DIR);
22
  Directory.CreateDirectory(BUNDLE_SUBDIR);
23
 
24
  string[] prefabPaths = Directory.GetFiles("Assets/InputRaw", "*.prefab", SearchOption.AllDirectories);
25
- if (prefabPaths.Length == 0) throw new Exception("Folder Assets/InputRaw kosong!");
26
-
27
  foreach (string path in prefabPaths)
28
  {
29
  string exportPath = Path.Combine(FINAL_EXPORT_DIR, Path.GetFileName(path));
@@ -40,15 +39,21 @@ public class TestBuilder
40
  AssetDatabase.SaveAssets();
41
  AssetDatabase.Refresh();
42
 
43
- // Build semua platform yang didukung oleh image ini
44
- BuildAllPlatforms();
 
 
 
 
 
 
45
 
46
- // Hapus master manifest biner (file bernama 'assetbundles') agar tidak mengganggu
47
  string masterBundle = Path.Combine(BUNDLE_SUBDIR, "assetbundles");
48
  if (File.Exists(masterBundle)) File.Delete(masterBundle);
49
  if (File.Exists(masterBundle + ".manifest")) File.Delete(masterBundle + ".manifest");
50
 
51
- Debug.Log("✅ [UNITY] Build selesai untuk semua platform yang tersedia.");
52
  EditorApplication.Exit(0);
53
  }
54
  catch (Exception e)
@@ -89,33 +94,15 @@ public class TestBuilder
89
  }
90
  }
91
 
92
- static void BuildAllPlatforms()
93
  {
94
- var platforms = new Dictionary<BuildTarget, BuildTargetGroup> {
95
- { BuildTarget.Android, BuildTargetGroup.Android },
96
- { BuildTarget.iOS, BuildTargetGroup.iOS },
97
- { BuildTarget.WebGL, BuildTargetGroup.WebGL },
98
- { BuildTarget.StandaloneWindows64, BuildTargetGroup.Standalone },
99
- { BuildTarget.StandaloneOSX, BuildTargetGroup.Standalone },
100
- { BuildTarget.StandaloneLinux64, BuildTargetGroup.Standalone }
101
- };
102
 
103
- foreach (var p in platforms)
104
- {
105
- if (!BuildPipeline.IsBuildTargetSupported(p.Value, p.Key)) {
106
- Debug.LogWarning($"⚠️ [SKIP] Platform {p.Key} tidak didukung oleh image ini.");
107
- continue;
108
- }
109
-
110
- AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
111
- buildMap[0].assetBundleName = p.Key.ToString();
112
- buildMap[0].assetNames = AssetDatabase.FindAssets("t:Prefab", new[] { FINAL_EXPORT_DIR })
113
- .Select(guid => AssetDatabase.GUIDToAssetPath(guid)).ToArray();
114
-
115
- BuildPipeline.BuildAssetBundles(BUNDLE_SUBDIR, buildMap,
116
- BuildAssetBundleOptions.ForceRebuildAssetBundle | BuildAssetBundleOptions.ChunkBasedCompression, p.Key);
117
-
118
- Debug.Log($"📦 [SUCCESS] Binary untuk {p.Key} berhasil dibuat.");
119
- }
120
  }
121
  }
 
15
  {
16
  try
17
  {
18
+ Debug.Log("🛠️ [UNITY] Memulai Export Standalone Linux & Android...");
19
 
20
  if (Directory.Exists(FINAL_EXPORT_DIR)) Directory.Delete(FINAL_EXPORT_DIR, true);
21
  Directory.CreateDirectory(FINAL_EXPORT_DIR);
22
  Directory.CreateDirectory(BUNDLE_SUBDIR);
23
 
24
  string[] prefabPaths = Directory.GetFiles("Assets/InputRaw", "*.prefab", SearchOption.AllDirectories);
25
+
 
26
  foreach (string path in prefabPaths)
27
  {
28
  string exportPath = Path.Combine(FINAL_EXPORT_DIR, Path.GetFileName(path));
 
39
  AssetDatabase.SaveAssets();
40
  AssetDatabase.Refresh();
41
 
42
+ // 1. BUILD LINUX
43
+ BuildPlatforms(BuildTarget.StandaloneLinux64);
44
+
45
+ // 2. BUILD ANDROID (Hanya jika modul tersedia)
46
+ if (BuildPipeline.IsBuildTargetSupported(BuildTargetGroup.Android, BuildTarget.Android))
47
+ {
48
+ BuildPlatforms(BuildTarget.Android);
49
+ }
50
 
51
+ // --- PEMBERSIHAN FILE 'assetbundles' ---
52
  string masterBundle = Path.Combine(BUNDLE_SUBDIR, "assetbundles");
53
  if (File.Exists(masterBundle)) File.Delete(masterBundle);
54
  if (File.Exists(masterBundle + ".manifest")) File.Delete(masterBundle + ".manifest");
55
 
56
+ Debug.Log("✅ [UNITY] Build Selesai. Master manifest dihapus.");
57
  EditorApplication.Exit(0);
58
  }
59
  catch (Exception e)
 
94
  }
95
  }
96
 
97
+ static void BuildPlatforms(BuildTarget target)
98
  {
99
+ AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
100
+ buildMap[0].assetBundleName = target.ToString();
101
+ buildMap[0].assetNames = AssetDatabase.FindAssets("t:Prefab", new[] { FINAL_EXPORT_DIR })
102
+ .Select(guid => AssetDatabase.GUIDToAssetPath(guid)).ToArray();
 
 
 
 
103
 
104
+ BuildPipeline.BuildAssetBundles(BUNDLE_SUBDIR, buildMap,
105
+ BuildAssetBundleOptions.ForceRebuildAssetBundle | BuildAssetBundleOptions.ChunkBasedCompression,
106
+ target);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
  }