Files
cppk-ar/Assets/Editor/x64/Bakery/scripts/ftTextureProcessor.cs
T
2022-10-13 16:19:21 +05:00

58 lines
1.8 KiB
C#

using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
public class ftTextureProcessor : AssetPostprocessor
{
public static Dictionary<string, Vector2> texSettings = new Dictionary<string, Vector2>();
static BakeryProjectSettings pstorage;
public const int TEX_LM = 0;
public const int TEX_LMDEFAULT = 1;
public const int TEX_MASK = 2;
public const int TEX_DIR = 3;
void OnPreprocessTexture()
{
TextureImporter importer = assetImporter as TextureImporter;
Vector2 settings;
if (!texSettings.TryGetValue(importer.assetPath, out settings)) return;
if (pstorage == null) pstorage = ftLightmaps.GetProjectSettings();
importer.maxTextureSize = (int)settings.x;
importer.mipmapEnabled = pstorage.mipmapLightmaps;
importer.wrapMode = TextureWrapMode.Clamp;
int texType = (int)settings.y;
switch(texType)
{
case TEX_LM:
{
importer.textureType = TextureImporterType.Lightmap;
break;
}
case TEX_LMDEFAULT:
{
importer.textureType = TextureImporterType.Default;
break;
}
case TEX_MASK:
{
importer.textureType = TextureImporterType.Default;
importer.textureCompression = TextureImporterCompression.CompressedHQ;
break;
}
case TEX_DIR:
{
importer.textureType = TextureImporterType.Default;
importer.textureCompression = TextureImporterCompression.CompressedHQ;
importer.sRGBTexture = (pstorage.format8bit == BakeryProjectSettings.FileFormat.PNG);
break;
}
}
}
}