Spaces:
Sleeping
Sleeping
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
|
| 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 |
-
//
|
| 43 |
-
BuildPlatforms(BuildTarget.StandaloneLinux64);
|
| 44 |
|
| 45 |
-
//
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
//
|
| 52 |
-
|
| 53 |
-
if (File.Exists(masterBundle)) File.Delete(masterBundle);
|
| 54 |
-
if (File.Exists(masterBundle + ".manifest")) File.Delete(masterBundle + ".manifest");
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
EditorApplication.Exit(0);
|
| 58 |
}
|
| 59 |
catch (Exception e)
|
|
@@ -94,10 +109,20 @@ public class TestBuilder
|
|
| 94 |
}
|
| 95 |
}
|
| 96 |
|
| 97 |
-
|
|
|
|
| 98 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
|
| 100 |
-
buildMap[0].assetBundleName =
|
| 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 |
|