Spaces:
Sleeping
Sleeping
Update UnityProject/Assets/Editor/TestBuilder.cs
Browse files12345673 unmodified lines111213141516171 unmodified line192021222324252627282930313233343536373839404 unmodified lines454647484950512 unmodified lines54555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154using UnityEngine;using UnityEditor;using System.IO;using System.Linq;public class TestBuilder{3 unmodified linespublic static void ManualConvert(){Debug.Log("==================================================");Debug.Log("🚀 [LOG MULAI] Unity AssetBundle Builder");Debug.Log("==================================================");try1 unmodified lineAssetDatabase.Refresh();// 1. CEK ISI FOLDER FISIK (DEBUGGING)string sysPath = Path.Combine(Directory.GetCurrentDirectory(), RAW_PATH);if(Directory.Exists(sysPath)) {string[] files = Directory.GetFiles(sysPath);Debug.Log($"📂 [DEBUG] File fisik di {RAW_PATH}:");foreach(var f in files) Debug.Log($" - {Path.GetFileName(f)}");} else {Debug.LogError($"⌠[FATAL] Folder fisik tidak ditemukan: {sysPath}");}// 2. CARI ASSET YANG BISA DIOLAH (Prefab, FBX, OBJ)// Kita cari semua jenis file 3D dan Prefabstring[] guids = AssetDatabase.FindAssets("t:GameObject", new[] { RAW_PATH });if (guids.Length == 0){Debug.LogError("⌠[FATAL] Tidak ada aset GameObject (Prefab/FBX) yang terbaca Unity!");EditorApplication.Exit(1);return;}4 unmodified lines// 3. SET BUNDLE NAMEAssetImporter importer = AssetImporter.GetAtPath(assetPath);if (importer == null) {Debug.LogError($"⌠[FATAL] Importer null untuk: {assetPath}");EditorApplication.Exit(1);}importer.assetBundleName = "repacked_item.zepeto";2 unmodified lines// 4. BUILDif (!Directory.Exists(OUTPUT_DIR)) Directory.CreateDirectory(OUTPUT_DIR);Debug.Log("🔨 [INFO] Memulai BuildPipeline...");BuildPipeline.BuildAssetBundles(OUTPUT_DIR,BuildAssetBundleOptions.ForceRebuildAssetBundle,BuildTarget.StandaloneWindows64);// 5. CEK HASILstring expectedFile = Path.Combine(OUTPUT_DIR, "repacked_item.zepeto");if (File.Exists(expectedFile)) {Debug.Log($"🎉 [SUKSES] File output terbentuk: {expectedFile}");EditorApplication.Exit(0);} else {Debug.LogError("⌠[GAGAL] Build selesai tapi file output tidak ada!");EditorApplication.Exit(1);}}catch (System.Exception e){Debug.LogError($"💀 [EXCEPTION] Error Kritis: {e.Message}\n{e.StackTrace}");EditorApplication.Exit(1);}}}EOFcat > /opt/zepeto/UnityProject/Assets/Editor/TestBuilder.cs << 'EOF'using UnityEngine;using UnityEditor;using System.IO;using System.Linq;public class TestBuilder{static readonly string RAW_PATH = "Assets/InputRaw";static readonly string OUTPUT_DIR = "Assets/Output";public static void ManualConvert(){Debug.Log("==================================================");Debug.Log("🚀 [LOG MULAI] Unity AssetBundle Builder");Debug.Log("==================================================");try{AssetDatabase.Refresh();// 1. CEK ISI FOLDER FISIK (DEBUGGING)string sysPath = Path.Combine(Directory.GetCurrentDirectory(), RAW_PATH);if(Directory.Exists(sysPath)) {string[] files = Directory.GetFiles(sysPath);Debug.Log($"📂 [DEBUG] File fisik di {RAW_PATH}:");foreach(var f in files) Debug.Log($" - {Path.GetFileName(f)}");} else {Debug.LogError($"⌠[FATAL] Folder fisik tidak ditemukan: {sysPath}");}// 2. CARI ASSET YANG BISA DIOLAH (Prefab, FBX, OBJ)// Kita cari semua jenis file 3D dan Prefabstring[] guids = AssetDatabase.FindAssets("t:GameObject", new[] { RAW_PATH });if (guids.Length == 0){Debug.LogError("⌠[FATAL] Tidak ada aset GameObject (Prefab/FBX) yang terbaca Unity!");EditorApplication.Exit(1);return;}string assetPath = AssetDatabase.GUIDToAssetPath(guids[0]);Debug.Log($"✅ [INFO] Target Aset Ditemukan: {assetPath}");// 3. SET BUNDLE NAMEAssetImporter importer = AssetImporter.GetAtPath(assetPath);if (importer == null) {Debug.LogError($"⌠[FATAL] Importer null untuk: {assetPath}");EditorApplication.Exit(1);}importer.assetBundleName = "repacked_item.zepeto";Debug.Log($"🔹 [INFO] AssetBundle Name diset ke: {importer.assetBundleName}");// 4. BUILDif (!Directory.Exists(OUTPUT_DIR)) Directory.CreateDirectory(OUTPUT_DIR);Debug.Log("🔨 [INFO] Memulai BuildPipeline...");BuildPipeline.BuildAssetBundles(OUTPUT_DIR,BuildAssetBundleOptions.ForceRebuildAssetBundle,BuildTarget.StandaloneWindows64);// 5. CEK HASILstring expectedFile = Path.Combine(OUTPUT_DIR, "repacked_item.zepeto");if (File.Exists(expectedFile)) {Debug.Log($"🎉 [SUKSES] File output terbentuk: {expectedFile}");EditorApplication.Exit(0);} else {Debug.LogError("⌠[GAGAL] Build selesai tapi file output tidak ada!");EditorApplication.Exit(1);}}1234563 unmodified lines101112131415161 unmodified line18192021222324252627282930313233343536373839404 unmodified lines454647484950512 unmodified lines54555657585960616263646566676869707172737475767778798081828384using UnityEngine;using UnityEditor;using System.IO;public class TestBuilder{3 unmodified linespublic static void ManualConvert(){Debug.Log("==================================================");Debug.Log("🚀 [NATIVE] UNITY ASSET BUNDLE BUILDER STARTED");Debug.Log("==================================================");try1 unmodified lineAssetDatabase.Refresh();// 1. CEK ISI FOLDER FISIK (DEBUGGING)// Biar kita tahu file apa yang sebenarnya masukstring sysPath = Path.Combine(Directory.GetCurrentDirectory(), RAW_PATH);if(Directory.Exists(sysPath)) {string[] files = Directory.GetFiles(sysPath);Debug.Log($"📂 [DEBUG] Isi Folder InputRaw ({files.Length} files):");foreach(var f in files) Debug.Log($" - {Path.GetFileName(f)}");} else {Debug.LogError($"⌠[FATAL] Folder fisik tidak ditemukan: {sysPath}");}// 2. CARI ASSET (PREFAB / MODEL)// Kita cari t:Prefab (Prefab Unity) DAN t:Model (FBX/OBJ)string[] guids = AssetDatabase.FindAssets("t:Prefab t:Model", new[] { RAW_PATH });if (guids.Length == 0){Debug.LogError("⌠[FATAL] Unity tidak mendeteksi Prefab atau Model apapun di InputRaw!");EditorApplication.Exit(1);return;}4 unmodified lines// 3. SET BUNDLE NAMEAssetImporter importer = AssetImporter.GetAtPath(assetPath);if (importer == null) {Debug.LogError($"⌠[FATAL] Importer null untuk: {assetPath}. File mungkin korup.");EditorApplication.Exit(1);}importer.assetBundleName = "repacked_item.zepeto";2 unmodified lines// 4. BUILDif (!Directory.Exists(OUTPUT_DIR)) Directory.CreateDirectory(OUTPUT_DIR);Debug.Log("🔨 [INFO] Memulai BuildPipeline (StandaloneWindows64)...");var manifest = BuildPipeline.BuildAssetBundles(OUTPUT_DIR,BuildAssetBundleOptions.ForceRebuildAssetBundle,BuildTarget.StandaloneWindows64);if (manifest == null) {Debug.LogError("⌠[FATAL] BuildPipeline mengembalikan NULL. Build Gagal!");EditorApplication.Exit(1);}// 5. CEK HASIL// Unity kadang memberi nama output sesuai nama folder parent kalau single bundlestring expectedFile = Path.Combine(OUTPUT_DIR, "repacked_item.zepeto");if (File.Exists(expectedFile)) {Debug.Log($"🎉 [SUKSES] File output terbentuk: {expectedFile}");EditorApplication.Exit(0);} else {Debug.LogError("⌠[GAGAL] Build sukses tapi file output tidak ditemukan di path yang diharapkan!");// List isi output folder buat debugstring[] outFiles = Directory.GetFiles(OUTPUT_DIR);Debug.LogError($"📂 Isi Output Folder: {string.Join(", ", outFiles)}");EditorApplication.Exit(1);}}
UnityProject/Assets/Editor/TestBuilder.cs+19-89