-
Notifications
You must be signed in to change notification settings - Fork 174
/
AlembicImporterEditor.cs
66 lines (52 loc) · 2.95 KB
/
AlembicImporterEditor.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
64
65
66
#if UNITY_2017_1_OR_NEWER
using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.Experimental.AssetImporters;
namespace UTJ.Alembic
{
[CustomEditor(typeof(AlembicImporter))]
public class AlembicImporterEditor : ScriptedImporterEditor
{
public override void OnInspectorGUI()
{
var importer = serializedObject.targetObject as AlembicImporter;
var settings = importer.m_ImportSettings;
var serSettings = serializedObject.FindProperty(() => importer.m_ImportSettings);
AddEnumProperty(serializedObject.FindProperty(() => importer.m_importMode), "Import Mode", "", typeof(AlembicImportMode));
AddBoolProperty(serSettings.FindPropertyRelative(() => settings.m_swapHandedness), "Swap handedness", "");
AddBoolProperty(serSettings.FindPropertyRelative(() => settings.m_swapFaceWinding), "Swap face winding", "");
AddBoolProperty(serSettings.FindPropertyRelative(() => settings.m_submeshPerUVTile), "Submesh per UV tile", "");
AddEnumProperty(serSettings.FindPropertyRelative(() => settings.m_normalsMode), "Normals mode", "", settings.m_normalsMode.GetType());
AddEnumProperty(serSettings.FindPropertyRelative(() => settings.m_tangentsMode), "Tangent mode", "", settings.m_tangentsMode.GetType());
AddEnumProperty(serSettings.FindPropertyRelative(() => settings.m_aspectRatioMode), "Aspect ratio mode", "", settings.m_aspectRatioMode.GetType());
AddBoolProperty(serSettings.FindPropertyRelative(() => settings.m_useThreads), "Use threads", "");
AddIntProperty(serSettings.FindPropertyRelative(() => settings.m_sampleCacheSize), "Sample cache size", "");
base.ApplyRevertGUI();
}
private void AddBoolProperty(SerializedProperty porperty, string text, string tooltip)
{
var orgValue = porperty.boolValue;
var newValue = EditorGUILayout.Toggle(new GUIContent(text, tooltip), orgValue);
porperty.boolValue = newValue;
}
void AddEnumProperty(SerializedProperty porperty, string text, string tooltip, Type typeOfEnum)
{
Rect ourRect = EditorGUILayout.BeginHorizontal();
EditorGUI.BeginProperty(ourRect, GUIContent.none, porperty);
int selectionFromInspector = porperty.intValue;
string[] enumNamesList = System.Enum.GetNames(typeOfEnum);
var actualSelected = EditorGUILayout.Popup(text, selectionFromInspector, enumNamesList);
porperty.intValue = actualSelected;
EditorGUI.EndProperty();
EditorGUILayout.EndHorizontal();
}
void AddIntProperty(SerializedProperty porperty, string text, string tooltip)
{
var orgValue = porperty.intValue;
var newValue = EditorGUILayout.IntField(new GUIContent(text, tooltip), orgValue);
porperty.intValue = newValue;
}
}
}
#endif