Spaces:
webzepetoku
/
Sleeping

webzepetoku commited on
Commit
29a6fca
·
verified ·
1 Parent(s): eda3d3a

Update UnityProject/Assets/Editor/TestBuilder.cs

Browse files
UnityProject/Assets/Editor/TestBuilder.cs CHANGED
@@ -15,7 +15,7 @@ public class TestBuilder
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);
@@ -29,9 +29,12 @@ public class TestBuilder
29
  GameObject go = PrefabUtility.LoadPrefabContents(path);
30
  if (go != null)
31
  {
 
32
  ProcessAndEmbed(go, exportPath);
33
  PrefabUtility.SaveAsPrefabAsset(go, exportPath);
34
  PrefabUtility.UnloadPrefabContents(go);
 
 
35
  CopyRelatedFiles(Path.GetDirectoryName(path), FINAL_EXPORT_DIR);
36
  }
37
  }
@@ -39,21 +42,33 @@ public class TestBuilder
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,10 +109,20 @@ public class TestBuilder
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
 
 
15
  {
16
  try
17
  {
18
+ Debug.Log("🛠️ [UNITY] Memulai Export Multi-Platform...");
19
 
20
  if (Directory.Exists(FINAL_EXPORT_DIR)) Directory.Delete(FINAL_EXPORT_DIR, true);
21
  Directory.CreateDirectory(FINAL_EXPORT_DIR);
 
29
  GameObject go = PrefabUtility.LoadPrefabContents(path);
30
  if (go != null)
31
  {
32
+ // Tetap tanam Mesh ke Prefab (Embedding) - Logika Berhasil
33
  ProcessAndEmbed(go, exportPath);
34
  PrefabUtility.SaveAsPrefabAsset(go, exportPath);
35
  PrefabUtility.UnloadPrefabContents(go);
36
+
37
+ // Salin file pendukung (PNG, Shader, Meta)
38
  CopyRelatedFiles(Path.GetDirectoryName(path), FINAL_EXPORT_DIR);
39
  }
40
  }
 
42
  AssetDatabase.SaveAssets();
43
  AssetDatabase.Refresh();
44
 
45
+ // --- PROSES BUILD SEMUA PLATFORM ---
 
46
 
47
+ // 1. Linux (Original)
48
+ BuildBinary("StandaloneLinux64", BuildTarget.StandaloneLinux64);
49
+
50
+ // 2. Android
51
+ BuildBinary("Android", BuildTarget.Android);
52
+
53
+ // 3. iOS
54
+ BuildBinary("iOS", BuildTarget.iOS);
55
+
56
+ // 4. WebGL
57
+ BuildBinary("WebGL", BuildTarget.WebGL);
58
 
59
+ // 5. Windows
60
+ BuildBinary("StandaloneWindows64", BuildTarget.StandaloneWindows64);
 
 
61
 
62
+ // 6. Mac
63
+ BuildBinary("StandaloneOSX", BuildTarget.StandaloneOSX);
64
+
65
+ // --- PEMBERSIHAN FILE MASTER ---
66
+ // Menghapus biner bernama 'assetbundles' yang otomatis dibuat Unity
67
+ string masterFile = Path.Combine(BUNDLE_SUBDIR, "assetbundles");
68
+ if (File.Exists(masterFile)) File.Delete(masterFile);
69
+ if (File.Exists(masterFile + ".manifest")) File.Delete(masterFile + ".manifest");
70
+
71
+ Debug.Log("✅ [UNITY] Build Semua Platform Selesai. Master manifest dihapus.");
72
  EditorApplication.Exit(0);
73
  }
74
  catch (Exception e)
 
109
  }
110
  }
111
 
112
+ // Fungsi biner umum berdasarkan logika BuildLinuxBinary yang berhasil
113
+ static void BuildBinary(string bundleName, BuildTarget target)
114
  {
115
+ // Cek apakah platform disupport oleh modul yang ada di Docker
116
+ if (!BuildPipeline.IsBuildTargetSupported(BuildPipeline.GetBuildTargetGroup(target), target))
117
+ {
118
+ Debug.LogWarning($"⚠️ [SKIP] Platform {target} tidak disupport oleh modul Unity ini.");
119
+ return;
120
+ }
121
+
122
+ Debug.Log($"📦 [UNITY] Membangun binary untuk {target}...");
123
+
124
  AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
125
+ buildMap[0].assetBundleName = bundleName;
126
  buildMap[0].assetNames = AssetDatabase.FindAssets("t:Prefab", new[] { FINAL_EXPORT_DIR })
127
  .Select(guid => AssetDatabase.GUIDToAssetPath(guid)).ToArray();
128