-
Notifications
You must be signed in to change notification settings - Fork 1
/
ModelImportProcessor.cs
63 lines (54 loc) · 2.55 KB
/
ModelImportProcessor.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using UnityEngine;
using UnityEditor;
namespace III.AssetImportProcessor
{
/// <summary>
/// Configure Model import settings on first import.
/// </summary>
public class ModelImportProcessor : AssetPostprocessor
{
private void OnPreprocessModel()
{
// The variable "assetImporter" references the importer for the asset that is currently importing.
var importer = assetImporter as ModelImporter;
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)
{
// Model Import
// Scene
importer.globalScale = 1f;
importer.useFileUnits = true;
importer.bakeAxisConversion = true;
importer.importBlendShapes = false;
importer.importVisibility = false;
importer.importCameras = false;
importer.importLights = false;
importer.preserveHierarchy = false;
importer.sortHierarchyByName = true;
// Meshes
importer.meshCompression = ModelImporterMeshCompression.Off;
importer.isReadable = false;
importer.addCollider = false;
// Geometery
importer.keepQuads = false;
importer.weldVertices = true;
importer.importNormals = ModelImporterNormals.Import;
importer.importBlendShapeNormals = ModelImporterNormals.None;
importer.normalCalculationMode = ModelImporterNormalCalculationMode.AreaAndAngleWeighted;
importer.normalSmoothingSource = ModelImporterNormalSmoothingSource.FromSmoothingGroups;
importer.importTangents = ModelImporterTangents.CalculateMikk;
importer.swapUVChannels = false;
importer.generateSecondaryUV = false;
// Rig Import
importer.animationType = ModelImporterAnimationType.None;
// Animation Import
importer.importConstraints = false;
importer.importAnimation = false;
// Material Import
importer.materialImportMode = ModelImporterMaterialImportMode.None;
Debug.Log("Model Import: override import settings for: " + importer.assetPath);
}
}
}
}