Spaces:
Sleeping
Sleeping
Update UnityProject/Assets/Editor/TestBuilder.cs
Browse files1234562 unmodified lines91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162using UnityEngine;using UnityEditor;using System.IO;public class TestBuilder{2 unmodified linespublic 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);}}12345672 unmodified lines101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160using UnityEngine;using UnityEditor;using System.IO;using System.Linq;public class TestBuilder{2 unmodified linespublic 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);}}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);}}catch (System.Exception e){Debug.LogError($"💀 [EXCEPTION] Error Kritis: {e.Message}\n{e.StackTrace}");EditorApplication.Exit(1);}}
UnityProject/Assets/Editor/TestBuilder.cs+114-16