webzepetoku commited on
Commit
12ef1fc
·
verified ·
1 Parent(s): ce7410b

Update UnityProject/Assets/Editor/TestBuilder.cs

Browse files
UnityProject/Assets/Editor/TestBuilder.cs CHANGED
@@ -4,68 +4,59 @@ using System.IO;
4
 
5
  public class TestBuilder
6
  {
7
- // Path Input dan Output
8
  static readonly string RAW_PATH = "Assets/InputRaw";
9
  static readonly string OUTPUT_DIR = "Assets/Output";
10
 
11
- // KITA PAKAI FUNGSI INI SAJA (NATIVE UNITY)
12
  public static void ManualConvert()
13
  {
14
- Debug.Log("🚀 [NATIVE] Memulai Build AssetBundle...");
15
 
16
  try
17
  {
18
- // 1. Refresh Asset Database
19
  AssetDatabase.Refresh();
20
 
21
- // 2. Cari Prefab di InputRaw
22
  string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { RAW_PATH });
23
  if (guids.Length == 0)
24
  {
25
- Debug.LogError("❌ Error: Tidak ada Prefab di Assets/InputRaw!");
26
  EditorApplication.Exit(1);
27
  return;
28
  }
29
 
30
- // Ambil path prefab
31
  string prefabPath = AssetDatabase.GUIDToAssetPath(guids[0]);
32
- Debug.Log($"📄 Menggunakan Prefab: {prefabPath}");
33
 
34
- // 3. SET ASSETBUNDLE NAME (Pura-pura jadi .zepeto)
35
  AssetImporter importer = AssetImporter.GetAtPath(prefabPath);
36
- if (importer == null)
37
- {
38
- Debug.LogError("❌ Gagal load AssetImporter.");
39
  EditorApplication.Exit(1);
40
  }
 
41
  importer.assetBundleName = "repacked_item.zepeto";
42
 
43
- // 4. SIAPKAN FOLDER OUTPUT
44
  if (!Directory.Exists(OUTPUT_DIR)) Directory.CreateDirectory(OUTPUT_DIR);
45
 
46
- // 5. BUILD MURNI (Target Windows64 paling stabil di Docker)
47
  BuildPipeline.BuildAssetBundles(
48
  OUTPUT_DIR,
49
  BuildAssetBundleOptions.ForceRebuildAssetBundle,
50
  BuildTarget.StandaloneWindows64
51
  );
52
 
53
- // 6. VERIFIKASI FILE
54
- string expectedFile = Path.Combine(OUTPUT_DIR, "repacked_item.zepeto");
55
- if (File.Exists(expectedFile))
56
- {
57
- Debug.Log($"✅ SUKSES! File output: {expectedFile}");
58
  EditorApplication.Exit(0);
59
- }
60
- else
61
- {
62
- Debug.LogError("❌ Gagal! File output tidak terbentuk.");
63
  EditorApplication.Exit(1);
64
  }
65
  }
66
  catch (System.Exception e)
67
  {
68
- Debug.LogError($"❌ CRITICAL ERROR: {e.Message}");
69
  EditorApplication.Exit(1);
70
  }
71
  }
 
4
 
5
  public class TestBuilder
6
  {
 
7
  static readonly string RAW_PATH = "Assets/InputRaw";
8
  static readonly string OUTPUT_DIR = "Assets/Output";
9
 
 
10
  public static void ManualConvert()
11
  {
12
+ Debug.Log("🚀 [NATIVE] Memulai Build AssetBundle...");
13
 
14
  try
15
  {
 
16
  AssetDatabase.Refresh();
17
 
18
+ // 1. Cari Prefab
19
  string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { RAW_PATH });
20
  if (guids.Length == 0)
21
  {
22
+ Debug.LogError("❌ Error: Tidak ada Prefab di Assets/InputRaw!");
23
  EditorApplication.Exit(1);
24
  return;
25
  }
26
 
 
27
  string prefabPath = AssetDatabase.GUIDToAssetPath(guids[0]);
28
+ Debug.Log($"📄 Prefab ditemukan: {prefabPath}");
29
 
30
+ // 2. Set AssetBundle Name
31
  AssetImporter importer = AssetImporter.GetAtPath(prefabPath);
32
+ if (importer == null) {
33
+ Debug.LogError("❌ Gagal load AssetImporter.");
 
34
  EditorApplication.Exit(1);
35
  }
36
+ // Ubah ekstensi jadi .zepeto (trik native)
37
  importer.assetBundleName = "repacked_item.zepeto";
38
 
39
+ // 3. Build AssetBundle
40
  if (!Directory.Exists(OUTPUT_DIR)) Directory.CreateDirectory(OUTPUT_DIR);
41
 
 
42
  BuildPipeline.BuildAssetBundles(
43
  OUTPUT_DIR,
44
  BuildAssetBundleOptions.ForceRebuildAssetBundle,
45
  BuildTarget.StandaloneWindows64
46
  );
47
 
48
+ // 4. Cek Hasil
49
+ if (File.Exists(Path.Combine(OUTPUT_DIR, "repacked_item.zepeto"))) {
50
+ Debug.Log("✅ Build Success!");
 
 
51
  EditorApplication.Exit(0);
52
+ } else {
53
+ Debug.LogError("❌ File output tidak terbentuk!");
 
 
54
  EditorApplication.Exit(1);
55
  }
56
  }
57
  catch (System.Exception e)
58
  {
59
+ Debug.LogError($"❌ CRITICAL ERROR: {e.Message}");
60
  EditorApplication.Exit(1);
61
  }
62
  }