Spaces:
Sleeping
Sleeping
Update UnityProject/Assets/Editor/TestBuilder.cs
Browse files55 unmodified lines565758596061624 unmodified lines676869707172732 unmodified lines767778798081822 unmodified lines85868788899091929394959697989910010110210310410510610710810911011111211311411555 unmodified lines}}// --- PEMBERSIHAN RAM AWAL ---EditorUtility.UnloadUnusedAssetsImmediate();GC.Collect();4 unmodified linesforeach (string path in allAssets){// Beri label bundle sesuai nama platform (agar binary masuk ke assetbundles)AssetImporter importer = AssetImporter.GetAtPath(path);if (importer != null) importer.assetBundleName = platformName;}2 unmodified linestry{// Binary dilempar ke dalam sub-folder assetbundles/BuildPipeline.BuildAssetBundles(ASSETBUNDLE_DIR,BuildAssetBundleOptions.ForceRebuildAssetBundle,2 unmodified lines}catch (System.Exception ex){Debug.LogWarning($"⚠️ [UNITY] Gagal build untuk {platformName}. Error: {ex.Message}");}// --- PEMBERSIHAN RAM SETIAP SELESAI SATU PLATFORM (Mencegah Exit Code 137) ---EditorUtility.UnloadUnusedAssetsImmediate();GC.Collect();}// 5. PROSES REPACKING FOLDER UTAMA MENJADI .ZEPETO DENGAN TIMESTAMP UNIKDebug.Log($"📦 [UNITY] Memulai proses repacking Folder Utama ({MAIN_FOLDER}) menjadi .zepeto...");// PEMBUATAN NAMA FILE UNIK DENGAN TIMESTAMPstring timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");string repackFile = $"Assets/Repacked_{timestamp}.zepeto";if (File.Exists(repackFile)){File.Delete(repackFile);}// Yang di-pack adalah folder utama (isinya: prefab, assetbundles, dsb)ZipFile.CreateFromDirectory(MAIN_FOLDER, repackFile);Debug.Log($"✅ [UNITY] Repacking selesai: {repackFile}");Debug.Log("✅ [UNITY] Seluruh rangkaian build dan repacking selesai.");EditorApplication.Exit(0);}catch (System.Exception e) {55 unmodified lines565758596061624 unmodified lines6768697071722 unmodified lines7576777879802 unmodified lines838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912055 unmodified lines}}// --- PEMBERSIHAN RAM AGRESIF SETELAH SIMPLIFY ---EditorUtility.UnloadUnusedAssetsImmediate();GC.Collect();4 unmodified linesforeach (string path in allAssets){AssetImporter importer = AssetImporter.GetAtPath(path);if (importer != null) importer.assetBundleName = platformName;}2 unmodified linestry{BuildPipeline.BuildAssetBundles(ASSETBUNDLE_DIR,BuildAssetBundleOptions.ForceRebuildAssetBundle,2 unmodified lines}catch (System.Exception ex){Debug.LogWarning($"⚠️ [UNITY] Gagal build untuk {platformName}. Modul tidak tersedia. Error: {ex.Message}");}// --- PEMBERSIHAN RAM SETIAP SELESAI SATU PLATFORM (Penting untuk mencegah 137) ---EditorUtility.UnloadUnusedAssetsImmediate();GC.Collect();Resources.UnloadUnusedAssets();}// 5. PROSES REPACKING DENGAN TIMESTAMP UNIK// Mengambil nama folder utama (misal 'InputRaw' atau 'hairku')string folderName = new DirectoryInfo(MAIN_FOLDER).Name;string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");// NAMA FILE HARUS UNIK (Contoh: hairku_20260219_180800.zepeto)string fileName = $"{folderName}_{timestamp}.zepeto";string repackFile = Path.Combine("Assets", fileName);Debug.Log($"📦 [PACKING] Membuat archive {fileName}...");if (File.Exists(repackFile)){File.Delete(repackFile);}// Pack seluruh folder utama termasuk sub-folder assetbundlesZipFile.CreateFromDirectory(MAIN_FOLDER, repackFile);Debug.Log($"✅ [UNITY] Build & Repacking Sukses: {repackFile}");// Segarkan agar file baru muncul di sistemAssetDatabase.Refresh();EditorApplication.Exit(0);}catch (System.Exception e) {
UnityProject/Assets/Editor/TestBuilder.cs+18-13