Spaces:
Sleeping
Sleeping
Download UnityProject/Assets/TestBuilder.cs from webzepetoku/multi: direct link, hf CLI and curl.
- Browser
- Download file 3.14 kB
-
https://huggingface.co/spaces/webzepetoku/multi/resolve/0f9a8d12a3c158366de97f30c665979b0a66232c/UnityProject/Assets/TestBuilder.cs
- Command line
-
hf download hf://spaces/webzepetoku/multi@0f9a8d12a3c158366de97f30c665979b0a66232c/UnityProject/Assets/TestBuilder.cs
-
curl -L -o TestBuilder.cs https://huggingface.co/spaces/webzepetoku/multi/resolve/0f9a8d12a3c158366de97f30c665979b0a66232c/UnityProject/Assets/TestBuilder.cs
3.14 kB
| using UnityEngine; | |
| using UnityEditor; | |
| using System; | |
| using System.IO; | |
| using UnityMeshSimplifier; // Pastikan folder plugin ini ada di Assets | |
| public class TestBuilder | |
| { | |
| public static void ManualConvert() | |
| { | |
| try | |
| { | |
| // 1. PAKSA 4 WORKER (Agar tidak menggunakan 16 thread CPU) | |
| Unity.Jobs.LowLevel.Unsafe.JobsUtility.JobWorkerCount = 4; | |
| Debug.Log($"βοΈ [CLI] Job Worker Count diset ke: {Unity.Jobs.LowLevel.Unsafe.JobsUtility.JobWorkerCount}"); | |
| // 2. FIX BACKEND (Wajib Mono2x untuk Unity 2022.3) | |
| PlayerSettings.SetScriptingBackend(BuildTargetGroup.Standalone, ScriptingImplementation.Mono2x); | |
| PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.Mono2x); | |
| PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, ScriptingImplementation.Mono2x); | |
| // 3. PROSES PERAMPINGAN MESH (Optimasi) | |
| string inputPath = "Assets/InputRaw"; | |
| if (Directory.Exists(inputPath)) | |
| { | |
| string[] prefabs = Directory.GetFiles(inputPath, "*.prefab", SearchOption.AllDirectories); | |
| foreach (string path in prefabs) | |
| { | |
| GameObject go = PrefabUtility.LoadPrefabContents(path); | |
| if (go != null) | |
| { | |
| Debug.Log($"π¦ Merampingkan (Simplify) Mesh: {path}"); | |
| SimplifyAndEmbed(go, path); | |
| PrefabUtility.SaveAsPrefabAsset(go, path); | |
| PrefabUtility.UnloadPrefabContents(go); | |
| } | |
| } | |
| } | |
| AssetDatabase.SaveAssets(); | |
| AssetDatabase.Refresh(); | |
| // 4. JALANKAN PENGEPAKAN ZEPETO | |
| Debug.Log("π [CLI] Menjalankan Pengepakan ZEPETO..."); | |
| ZepetoPackageCliBuilder.BuildWithArgs(); | |
| Debug.Log("β [CLI] Selesai."); | |
| EditorApplication.Exit(0); | |
| } | |
| catch (Exception e) | |
| { | |
| Debug.LogError($"π [ERROR] {e.Message}"); | |
| EditorApplication.Exit(1); | |
| } | |
| } | |
| static void SimplifyAndEmbed(GameObject go, string assetPath) | |
| { | |
| var renderers = go.GetComponentsInChildren<Renderer>(); | |
| foreach (var ren in renderers) | |
| { | |
| Mesh src = (ren is MeshRenderer mr) ? ren.GetComponent<MeshFilter>()?.sharedMesh : | |
| (ren is SkinnedMeshRenderer smr) ? smr.sharedMesh : null; | |
| if (src != null) | |
| { | |
| var simplifier = new MeshSimplifier(); | |
| simplifier.Initialize(src); | |
| simplifier.SimplifyMesh(0.05f); // Sisakan 5% poligon (Perampingan agresif) | |
| Mesh newMesh = simplifier.ToMesh(); | |
| newMesh.name = src.name + "_Optimized"; | |
| AssetDatabase.AddObjectToAsset(newMesh, assetPath); | |
| if (ren is MeshRenderer) ren.GetComponent<MeshFilter>().sharedMesh = newMesh; | |
| else if (ren is SkinnedMeshRenderer s) s.sharedMesh = newMesh; | |
| } | |
| } | |
| } | |
| } |