-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplyMeshCompression.cs
30 lines (26 loc) · 1.12 KB
/
ApplyMeshCompression.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
using UnityEditor;
public class ApplyMeshCompression : MonoBehaviour
{
[MenuItem("Tools/Italiandogs/Apply Mesh Compression")]
public static void ApplyMeshCompressionToSceneObjects()
{
// Get all mesh filters in the active scene
var meshFilters = FindObjectsOfType<MeshFilter>();
foreach (var meshFilter in meshFilters)
{
if (meshFilter.sharedMesh != null)
{
string path = AssetDatabase.GetAssetPath(meshFilter.sharedMesh);
ModelImporter importer = AssetImporter.GetAtPath(path) as ModelImporter;
if (importer != null && importer.meshCompression == ModelImporterMeshCompression.Off)
{
importer.meshCompression = ModelImporterMeshCompression.Medium;
importer.SaveAndReimport();
Debug.Log($"Applied medium mesh compression to: {meshFilter.sharedMesh.name}");
}
}
}
Debug.Log("Finished applying medium mesh compression to meshes without compression.");
}
}