Initial Commit
This commit is contained in:
commit
13767d3f40
160 changed files with 51070 additions and 0 deletions
48
PlatformMeshCompression.cs
Normal file
48
PlatformMeshCompression.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class PlatformMeshCompression : AssetPostprocessor
|
||||
{
|
||||
// Map GUIDs to compression settings: (PC, Android)
|
||||
static readonly Dictionary<string, (ModelImporterMeshCompression pc, ModelImporterMeshCompression android)> compressionMap
|
||||
= new Dictionary<string, (ModelImporterMeshCompression, ModelImporterMeshCompression)>
|
||||
{
|
||||
{ "e82fc872936dfa44a8653aab54da1bba", (ModelImporterMeshCompression.Off, ModelImporterMeshCompression.Medium) },
|
||||
};
|
||||
|
||||
static PlatformMeshCompression()
|
||||
{
|
||||
EditorApplication.delayCall += ReimportMappedAssets;
|
||||
}
|
||||
|
||||
static void ReimportMappedAssets()
|
||||
{
|
||||
foreach (var guid in compressionMap.Keys)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnPreprocessModel()
|
||||
{
|
||||
var modelImporter = (ModelImporter)assetImporter;
|
||||
string guid = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
|
||||
if (compressionMap.TryGetValue(guid, out var compressions))
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
modelImporter.meshCompression = compressions.android;
|
||||
#else
|
||||
modelImporter.meshCompression = compressions.pc;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue