-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathModelImporterUtil.cs
39 lines (33 loc) · 1.56 KB
/
ModelImporterUtil.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
using System.Reflection;
using UnityEditor;
using UnityEngine.Assertions;
namespace VRWorldToolkit.Editor
{
/// <summary>
/// Utility for setting and getting internal model importer values
/// </summary>
public static class ModelImporterUtil
{
private static readonly System.Type systemType;
private static PropertyInfo mProperty_LegacyBlendShapeNormals;
static ModelImporterUtil()
{
systemType = Assembly.Load("UnityEditor.dll").GetType("UnityEditor.ModelImporter");
Assert.IsNotNull(systemType);
}
public static bool GetLegacyBlendShapeNormals(ModelImporter importer)
{
if (mProperty_LegacyBlendShapeNormals == null)
mProperty_LegacyBlendShapeNormals = systemType.GetProperty("legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.IsNotNull(mProperty_LegacyBlendShapeNormals);
return (bool)mProperty_LegacyBlendShapeNormals.GetValue(importer);
}
public static void SetLegacyBlendShapeNormals(ModelImporter importer, bool value)
{
if (mProperty_LegacyBlendShapeNormals == null)
mProperty_LegacyBlendShapeNormals = systemType.GetProperty("legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.IsNotNull(mProperty_LegacyBlendShapeNormals);
mProperty_LegacyBlendShapeNormals.SetValue(importer, value, null);
}
}
}