Spaces:
Running
Running
Update UnityProject/Assets/Editor/TestBuilder.cs
Browse files3 unmodified lines45678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970713 unmodified linespublic class TestBuilder{// Path Input dan Outputstatic readonly string RAW_PATH = "Assets/InputRaw";static readonly string OUTPUT_DIR = "Assets/Output";// KITA PAKAI FUNGSI INI SAJA (NATIVE UNITY)public static void ManualConvert(){Debug.Log("🚀 [NATIVE] Memulai Build AssetBundle...");try{// 1. Refresh Asset DatabaseAssetDatabase.Refresh();// 2. Cari Prefab di InputRawstring[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { RAW_PATH });if (guids.Length == 0){Debug.LogError("❌ Error: Tidak ada Prefab di Assets/InputRaw!");EditorApplication.Exit(1);return;}// Ambil path prefabstring prefabPath = AssetDatabase.GUIDToAssetPath(guids[0]);Debug.Log($"📄 Menggunakan Prefab: {prefabPath}");// 3. SET ASSETBUNDLE NAME (Pura-pura jadi .zepeto)AssetImporter importer = AssetImporter.GetAtPath(prefabPath);if (importer == null){Debug.LogError("❌ Gagal load AssetImporter.");EditorApplication.Exit(1);}importer.assetBundleName = "repacked_item.zepeto";// 4. SIAPKAN FOLDER OUTPUTif (!Directory.Exists(OUTPUT_DIR)) Directory.CreateDirectory(OUTPUT_DIR);// 5. BUILD MURNI (Target Windows64 paling stabil di Docker)BuildPipeline.BuildAssetBundles(OUTPUT_DIR,BuildAssetBundleOptions.ForceRebuildAssetBundle,BuildTarget.StandaloneWindows64);// 6. VERIFIKASI FILEstring expectedFile = Path.Combine(OUTPUT_DIR, "repacked_item.zepeto");if (File.Exists(expectedFile)){Debug.Log($"✅ SUKSES! File output: {expectedFile}");EditorApplication.Exit(0);}else{Debug.LogError("❌ Gagal! File output tidak terbentuk.");EditorApplication.Exit(1);}}catch (System.Exception e){Debug.LogError($"❌ CRITICAL ERROR: {e.Message}");EditorApplication.Exit(1);}}3 unmodified lines45678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061623 unmodified linespublic class TestBuilder{static readonly string RAW_PATH = "Assets/InputRaw";static readonly string OUTPUT_DIR = "Assets/Output";public static void ManualConvert(){Debug.Log("🚀 [NATIVE] Memulai Build AssetBundle...");try{AssetDatabase.Refresh();// 1. Cari Prefabstring[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { RAW_PATH });if (guids.Length == 0){Debug.LogError("⌠Error: Tidak ada Prefab di Assets/InputRaw!");EditorApplication.Exit(1);return;}string prefabPath = AssetDatabase.GUIDToAssetPath(guids[0]);Debug.Log($"📄 Prefab ditemukan: {prefabPath}");// 2. Set AssetBundle NameAssetImporter importer = AssetImporter.GetAtPath(prefabPath);if (importer == null) {Debug.LogError("⌠Gagal load AssetImporter.");EditorApplication.Exit(1);}// Ubah ekstensi jadi .zepeto (trik native)importer.assetBundleName = "repacked_item.zepeto";// 3. Build AssetBundleif (!Directory.Exists(OUTPUT_DIR)) Directory.CreateDirectory(OUTPUT_DIR);BuildPipeline.BuildAssetBundles(OUTPUT_DIR,BuildAssetBundleOptions.ForceRebuildAssetBundle,BuildTarget.StandaloneWindows64);// 4. Cek Hasilif (File.Exists(Path.Combine(OUTPUT_DIR, "repacked_item.zepeto"))) {Debug.Log("✅ Build Success!");EditorApplication.Exit(0);} else {Debug.LogError("⌠File output tidak terbentuk!");EditorApplication.Exit(1);}}catch (System.Exception e){Debug.LogError($"⌠CRITICAL ERROR: {e.Message}");EditorApplication.Exit(1);}}
UnityProject/Assets/Editor/TestBuilder.cs+15-24