Spaces:
Sleeping
Sleeping
Update UnityProject/Assets/Editor/TestBuilder.cs
Browse files
UnityProject/Assets/Editor/TestBuilder.cs
CHANGED
|
@@ -56,7 +56,7 @@ public class TestBuilder
|
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
| 59 |
-
// --- PEMBERSIHAN RAM
|
| 60 |
EditorUtility.UnloadUnusedAssetsImmediate();
|
| 61 |
GC.Collect();
|
| 62 |
|
|
@@ -67,7 +67,6 @@ public class TestBuilder
|
|
| 67 |
|
| 68 |
foreach (string path in allAssets)
|
| 69 |
{
|
| 70 |
-
// Beri label bundle sesuai nama platform (agar binary masuk ke assetbundles)
|
| 71 |
AssetImporter importer = AssetImporter.GetAtPath(path);
|
| 72 |
if (importer != null) importer.assetBundleName = platformName;
|
| 73 |
}
|
|
@@ -76,7 +75,6 @@ public class TestBuilder
|
|
| 76 |
|
| 77 |
try
|
| 78 |
{
|
| 79 |
-
// Binary dilempar ke dalam sub-folder assetbundles/
|
| 80 |
BuildPipeline.BuildAssetBundles(
|
| 81 |
ASSETBUNDLE_DIR,
|
| 82 |
BuildAssetBundleOptions.ForceRebuildAssetBundle,
|
|
@@ -85,31 +83,38 @@ public class TestBuilder
|
|
| 85 |
}
|
| 86 |
catch (System.Exception ex)
|
| 87 |
{
|
| 88 |
-
Debug.LogWarning($"⚠️ [UNITY] Gagal build untuk {platformName}. Error: {ex.Message}");
|
| 89 |
}
|
| 90 |
|
| 91 |
-
// --- PEMBERSIHAN RAM SETIAP SELESAI SATU PLATFORM (
|
| 92 |
EditorUtility.UnloadUnusedAssetsImmediate();
|
| 93 |
GC.Collect();
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
-
// 5. PROSES REPACKING
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
// PEMBUATAN NAMA FILE UNIK DENGAN TIMESTAMP
|
| 100 |
string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
if (File.Exists(repackFile))
|
| 104 |
{
|
| 105 |
File.Delete(repackFile);
|
| 106 |
}
|
| 107 |
|
| 108 |
-
//
|
| 109 |
ZipFile.CreateFromDirectory(MAIN_FOLDER, repackFile);
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
-
|
|
|
|
| 113 |
EditorApplication.Exit(0);
|
| 114 |
}
|
| 115 |
catch (System.Exception e) {
|
|
|
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
| 59 |
+
// --- PEMBERSIHAN RAM AGRESIF SETELAH SIMPLIFY ---
|
| 60 |
EditorUtility.UnloadUnusedAssetsImmediate();
|
| 61 |
GC.Collect();
|
| 62 |
|
|
|
|
| 67 |
|
| 68 |
foreach (string path in allAssets)
|
| 69 |
{
|
|
|
|
| 70 |
AssetImporter importer = AssetImporter.GetAtPath(path);
|
| 71 |
if (importer != null) importer.assetBundleName = platformName;
|
| 72 |
}
|
|
|
|
| 75 |
|
| 76 |
try
|
| 77 |
{
|
|
|
|
| 78 |
BuildPipeline.BuildAssetBundles(
|
| 79 |
ASSETBUNDLE_DIR,
|
| 80 |
BuildAssetBundleOptions.ForceRebuildAssetBundle,
|
|
|
|
| 83 |
}
|
| 84 |
catch (System.Exception ex)
|
| 85 |
{
|
| 86 |
+
Debug.LogWarning($"⚠️ [UNITY] Gagal build untuk {platformName}. Modul tidak tersedia. Error: {ex.Message}");
|
| 87 |
}
|
| 88 |
|
| 89 |
+
// --- PEMBERSIHAN RAM SETIAP SELESAI SATU PLATFORM (Penting untuk mencegah 137) ---
|
| 90 |
EditorUtility.UnloadUnusedAssetsImmediate();
|
| 91 |
GC.Collect();
|
| 92 |
+
Resources.UnloadUnusedAssets();
|
| 93 |
}
|
| 94 |
|
| 95 |
+
// 5. PROSES REPACKING DENGAN TIMESTAMP UNIK
|
| 96 |
+
// Mengambil nama folder utama (misal 'InputRaw' atau 'hairku')
|
| 97 |
+
string folderName = new DirectoryInfo(MAIN_FOLDER).Name;
|
|
|
|
| 98 |
string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
| 99 |
+
|
| 100 |
+
// NAMA FILE HARUS UNIK (Contoh: hairku_20260219_180800.zepeto)
|
| 101 |
+
string fileName = $"{folderName}_{timestamp}.zepeto";
|
| 102 |
+
string repackFile = Path.Combine("Assets", fileName);
|
| 103 |
+
|
| 104 |
+
Debug.Log($"📦 [PACKING] Membuat archive {fileName}...");
|
| 105 |
|
| 106 |
if (File.Exists(repackFile))
|
| 107 |
{
|
| 108 |
File.Delete(repackFile);
|
| 109 |
}
|
| 110 |
|
| 111 |
+
// Pack seluruh folder utama termasuk sub-folder assetbundles
|
| 112 |
ZipFile.CreateFromDirectory(MAIN_FOLDER, repackFile);
|
| 113 |
+
|
| 114 |
+
Debug.Log($"✅ [UNITY] Build & Repacking Sukses: {repackFile}");
|
| 115 |
|
| 116 |
+
// Segarkan agar file baru muncul di sistem
|
| 117 |
+
AssetDatabase.Refresh();
|
| 118 |
EditorApplication.Exit(0);
|
| 119 |
}
|
| 120 |
catch (System.Exception e) {
|