-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTextureImportProcessor.cs
More file actions
39 lines (32 loc) · 1.49 KB
/
TextureImportProcessor.cs
File metadata and controls
39 lines (32 loc) · 1.49 KB
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
31
32
33
34
35
36
37
38
39
using UnityEngine;
using UnityEditor;
namespace III.AssetImportProcessor
{
/// <summary>
/// Configure Texture import settings on first import.
/// </summary>
public class TextureImportProcessor : AssetPostprocessor
{
private void OnPreprocessTexture()
{
// The variable "assetImporter" references the importer for the asset that is currently importing.
var importer = assetImporter as TextureImporter;
if (importer == null) return;
//If we already have a meta file for that asset it's a reimport and not a first import, so we don't want to apply the preset.
if (importer.importSettingsMissing)
{
string textureName = System.IO.Path.GetFileNameWithoutExtension(importer.assetPath);
if (textureName.EndsWith("_N"))
importer.textureType = TextureImporterType.NormalMap;
if (textureName.EndsWith("_GUI"))
importer.textureType = TextureImporterType.Sprite;
importer.isReadable = false;
importer.mipmapEnabled = true;
importer.wrapMode = TextureWrapMode.Clamp;
importer.filterMode = FilterMode.Trilinear;
importer.textureCompression = TextureImporterCompression.Compressed;
Debug.Log("Texture Import: override import settings for: " + importer.assetPath);
}
}
}
}