Tanoda
AssetLoaderOptionsEditor.cs
Go to the documentation of this file.
1using TriLibCore.General;
2using UnityEditor;
3using UnityEngine;
4
6{
7 [CustomEditor(typeof(AssetLoaderOptions))]
9 {
10 private int _currentTab;
11
12 public override void OnInspectorGUI()
13 {
14 ShowInspectorGUI(serializedObject, ref _currentTab);
15 }
16
17 public static void ShowInspectorGUI(SerializedObject serializedObject, ref int currentTab)
18 {
19 serializedObject.Update();
20 EditorGUILayout.BeginHorizontal();
21 if (GUILayout.Toggle(currentTab == 0, "Model", "LargeButtonLeft"))
22 {
23 currentTab = 0;
24 }
25 if (GUILayout.Toggle(currentTab == 1, "Rig", "LargeButtonMid"))
26 {
27 currentTab = 1;
28 }
29 if (GUILayout.Toggle(currentTab == 2, "Animations", "LargeButtonMid"))
30 {
31 currentTab = 2;
32 }
33 if (GUILayout.Toggle(currentTab == 3, "Materials", "LargeButtonMid"))
34 {
35 currentTab = 3;
36 }
37 if (GUILayout.Toggle(currentTab == 4, "Textures", "LargeButtonMid"))
38 {
39 currentTab = 4;
40 }
41 if (GUILayout.Toggle(currentTab == 5, "External Data", "LargeButtonRight"))
42 {
43 currentTab = 5;
44 }
45 EditorGUILayout.EndHorizontal();
46 EditorGUILayout.BeginVertical();
47 switch (currentTab)
48 {
49 case 0:
50 GUILayout.Label(new GUIContent("Scene", "Scene import settings"), "BoldLabel");
51 EditorGUILayout.PropertyField(serializedObject.FindProperty("ScaleFactor"), new GUIContent("Scale Factor", "Model scale multiplier."));
52 EditorGUILayout.PropertyField(serializedObject.FindProperty("UseFileScale"), new GUIContent("Use File Scale", "Turn on this flag to use the file original scale."));
53 EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportVisibility"), new GUIContent("Import Visibility", "Turn on this field to apply the visibility property to Mesh Renderers/Skinned Mesh Renderers."));
54 //todo: cameras and lights
55 EditorGUILayout.PropertyField(serializedObject.FindProperty("Static"), new GUIContent("Import as Static", "Turn on this field to import the Model as a static Game Object."));
56 EditorGUILayout.PropertyField(serializedObject.FindProperty("SortHierarchyByName"), new GUIContent("Sort Hierarchy by Name", "Turn on this field to sort the Model hierarchy by name."));
57 EditorGUILayout.PropertyField(serializedObject.FindProperty("AddAssetUnloader"), new GUIContent("Add Asset Unloader", "Turn on this field to add the Asset Unloader Component to the loaded Game Object."));
58 EditorGUILayout.PropertyField(serializedObject.FindProperty("ShowLoadingWarnings"), new GUIContent("Show Loading Warnings", "Turn on this field to display Model loading warnings on the Console."));
59 EditorGUILayout.PropertyField(serializedObject.FindProperty("CloseStreamAutomatically"), new GUIContent("Close Stream Automatically", "Turn on this field to close the Model loading Stream automatically."));
60 EditorGUILayout.PropertyField(serializedObject.FindProperty("DestroyOnError"), new GUIContent("Destroy on Error", "Turn on this field to destroy the loaded Game Object automatically when there is any loading error."));
61 EditorGUILayout.PropertyField(serializedObject.FindProperty("Timeout"), new GUIContent("Timeout", "Model loading timeout in seconds (0=disabled)."));
62 EditorGUILayout.PropertyField(serializedObject.FindProperty("ForceGCCollectionWhileLoading"), new GUIContent("Force GC Collection while loading", "Turn on this field to force the GC collection while loading the model and release memory promptly."));
63 EditorGUILayout.Space();
64 GUILayout.Label(new GUIContent("Meshes", "Global settings for generated meshes"), "BoldLabel");
65 var importMeshesProperty = serializedObject.FindProperty("ImportMeshes");
66 EditorGUILayout.PropertyField(importMeshesProperty, new GUIContent("Import Meshes", "Turn on this field to import Model Meshes."));
67 if (importMeshesProperty.boolValue)
68 {
69 EditorGUILayout.PropertyField(serializedObject.FindProperty("ReadAndWriteEnabled"), new GUIContent("Read and Write Enabled", "Turn on this field to optimize imported Meshes for reading/writing."));
70 EditorGUILayout.PropertyField(serializedObject.FindProperty("OptimizeMeshes"), new GUIContent("Optimize Meshes", "Turn on this field to optimize imported Meshes for GPU access."));
71 var generateCollidersProperty = serializedObject.FindProperty("GenerateColliders");
72 EditorGUILayout.PropertyField(generateCollidersProperty, new GUIContent("Generate Colliders", "Turn on this field to generate Colliders for imported Meshes."));
73 if (generateCollidersProperty.boolValue)
74 {
75 EditorGUILayout.PropertyField(serializedObject.FindProperty("ConvexColliders"), new GUIContent("Convex Colliders", "Turn on this field to generate convex Colliders when the GenerateColliders field is enabled."));
76 }
77 EditorGUILayout.Space();
78 GUILayout.Label(new GUIContent("Geometry", "Detailed mesh data"), "BoldLabel");
79 EditorGUILayout.PropertyField(serializedObject.FindProperty("KeepQuads"), new GUIContent("Keep Quads", "Turn on this field to mantain Mesh quads. (Useful for DX11 tesselation)"));
80 EditorGUILayout.PropertyField(serializedObject.FindProperty("IndexFormat"), new GUIContent("Index Format", "Mesh index format (16 or 32 bits)."));
81 EditorGUILayout.PropertyField(serializedObject.FindProperty("MergeVertices"), new GUIContent("Merge Vertices", "Turn on this field to merge model duplicated vertices where possible."));
82 EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportNormals"), new GUIContent("Import Normals", "Turn on this field to import Mesh normals. If not enabled, normals will be calculated instead."));
83 EditorGUILayout.Slider(serializedObject.FindProperty("SmoothingAngle"), 0f, 180f, new GUIContent("Smoothing Angle", "Normals calculation smoothing angle."));
84 EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportBlendShapes"), new GUIContent("Import Blend Shapes", "Turn on this field to import Mesh Blend Shapes."));
85 EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportBlendShapeNormals"), new GUIContent("Import Blend Shape Normals", "Turn on this field to import Mesh Blend Shape normals. If not enabled, normals will be calculated instead."));
86 EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportColors"), new GUIContent("Import Colors", "Turn on this field to import Mesh Colors."));
87 EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportTangents"), new GUIContent("Import Tangents", "Turn on this field to import Mesh tangents. If not enabled, tangents will be calculated instead."));
88 EditorGUILayout.PropertyField(serializedObject.FindProperty("SwapUVs"), new GUIContent("Swap UVs", "Turn on this field to swap Mesh UVs. (uv1 into uv2)"));
89 EditorGUILayout.PropertyField(serializedObject.FindProperty("LipSyncMappers"), new GUIContent("Lip Sync Mappers", "Mappers used to configure Lip-Sync Blend Shapes."));
90 }
91 break;
92 case 1:
93 var animationTypeProperty = serializedObject.FindProperty("AnimationType");
94 EditorGUILayout.PropertyField(animationTypeProperty, new GUIContent("Animation Type", "Model rigging type."));
95 var animationType = (AnimationType)animationTypeProperty.intValue;
96 switch (animationType)
97 {
98 case AnimationType.Generic:
99 case AnimationType.Humanoid:
100
101 var avatarDefinitionTypeProperty = serializedObject.FindProperty("AvatarDefinition");
102 EditorGUILayout.PropertyField(avatarDefinitionTypeProperty, new GUIContent("Avatar Definition", "Type of avatar creation for the Model."));
103 var avatarDefinitionType = (AvatarDefinitionType)avatarDefinitionTypeProperty.intValue;
104 switch (avatarDefinitionType)
105 {
106 case AvatarDefinitionType.CreateFromThisModel:
107 if (animationType == AnimationType.Humanoid)
108 {
109 EditorGUILayout.PropertyField(serializedObject.FindProperty("HumanDescription"), new GUIContent("Human Description", "HHuman Description used to create the humanoid Avatar, when the humanoid rigging type is selected."));
110 EditorGUILayout.PropertyField(serializedObject.FindProperty("SampleBindPose"), new GUIContent("Sample Bind Pose", "Turn on this field to enforce the loaded Model to the bind-pose when rigging."));
111 EditorGUILayout.PropertyField(serializedObject.FindProperty("EnforceTPose"), new GUIContent("Enforce T-Pose", "Turn on this field to enforce the loaded Model to the t-pose when rigging."));
112 EditorGUILayout.PropertyField(serializedObject.FindProperty("HumanoidAvatarMapper"), new GUIContent("Humanoid Avatar Mapper", "Mapper used to map the humanoid Avatar, when the humanoid rigging type is selected."));
113 }
114 break;
115 case AvatarDefinitionType.CopyFromOtherAvatar:
116 EditorGUILayout.PropertyField(serializedObject.FindProperty("Avatar"), new GUIContent("Source", "Source Avatar to use when copying from other Avatar."));
117 break;
118 }
119 break;
120 }
121 if (animationType != AnimationType.None)
122 {
123 EditorGUILayout.PropertyField(serializedObject.FindProperty("RootBoneMapper"), new GUIContent("Root Bone Mapper", "Mapper used to find the Model root bone."));
124 }
125 EditorGUILayout.PropertyField(serializedObject.FindProperty("LimitBoneWeights"), new GUIContent("Limit Bone Weights", "Turn on this field to limit bones weight to 4 weights per bone."));
126 break;
127 case 2:
128 animationTypeProperty = serializedObject.FindProperty("AnimationType");
129 animationType = (AnimationType)animationTypeProperty.intValue;
130 //todo: constraints
131 if (animationType != AnimationType.None)
132 {
133 EditorGUILayout.PropertyField(serializedObject.FindProperty("EnsureQuaternionContinuity"), new GUIContent("Ensure Quaternion Continuity", "Turn on this field to realign quaternion keys to ensure shortest interpolation paths."));
134 //todo: keyframe reduction
135 EditorGUILayout.PropertyField(serializedObject.FindProperty("AnimationWrapMode"), new GUIContent("Wrap Mode", "Default wrap-mode to apply to Animations."));
136 EditorGUILayout.PropertyField(serializedObject.FindProperty("AnimationClipMappers"), new GUIContent("Animation Clip Mappers", "Mappers used to process Animation Clips."));
137 }
138 break;
139 case 3:
140 var importMaterialsProperty = serializedObject.FindProperty("ImportMaterials");
141 EditorGUILayout.PropertyField(importMaterialsProperty, new GUIContent("Import Materials", "Turn on this field to import Materials."));
142 if (importMaterialsProperty.boolValue)
143 {
144 EditorGUILayout.PropertyField(serializedObject.FindProperty("UseMaterialKeywords"), new GUIContent("Use Material Keywords", "Turn on this field to enable/disable created Material Keywords based on the source native Materials."));
145 var useAlphaMaterials = serializedObject.FindProperty("UseAlphaMaterials");
146 EditorGUILayout.PropertyField(useAlphaMaterials, new GUIContent("Use Alpha Materials", "Turn on this field to enable alpha (transparent) Materials creation."));
147 if (useAlphaMaterials.boolValue)
148 {
149 EditorGUILayout.PropertyField(serializedObject.FindProperty("AddSecondAlphaMaterial"), new GUIContent("Add Second Alpha Material", "Turn on this field to add a second-pass to alpha Materials and make they write to the depth-channel."));
150 }
151 EditorGUILayout.PropertyField(serializedObject.FindProperty("MaterialMappers"), new GUIContent("Material Mappers", "Mappers used to create suitable Unity Materials from original Materials."));
152 }
153 break;
154 case 4:
155 var importTexturesProperty = serializedObject.FindProperty("ImportTextures");
156 EditorGUILayout.PropertyField(importTexturesProperty, new GUIContent("Import Textures", "Turn on this field to import Textures."));
157 if (importTexturesProperty.boolValue)
158 {
159 EditorGUILayout.PropertyField(serializedObject.FindProperty("TextureMapper"), new GUIContent("Texture Mapper", "Mapper used to find native Texture Streams from custom sources."));
160 EditorGUILayout.PropertyField(serializedObject.FindProperty("TextureCompressionQuality"), new GUIContent("Texture Compression Quality", "Texture compression to apply on loaded Textures."));
161 EditorGUILayout.PropertyField(serializedObject.FindProperty("GenerateMipmaps"), new GUIContent("Generate Mipmaps", "Turn on this field to enable Textures mip-map generation."));
162 EditorGUILayout.PropertyField(serializedObject.FindProperty("FixNormalMaps"), new GUIContent("Fix Normal Maps", "Turn on this field to swap normal map Textures channel R with channel A. (This setting may work for some platforms, but not others)"));
163 EditorGUILayout.PropertyField(serializedObject.FindProperty("Enforce16BitsTextures"), new GUIContent("Enforce 16 Bits Textures", "Turn on this field to import Textures as 16-bits HDR."));
164 EditorGUILayout.PropertyField(serializedObject.FindProperty("MarkTexturesNoLongerReadable"), new GUIContent("Mark Textures no longer readable", "Turn on this field to set textures as no longer readable and release memory resources."));
165 var useAlphaMaterials = serializedObject.FindProperty("UseAlphaMaterials");
166 if (useAlphaMaterials.boolValue)
167 {
168 EditorGUILayout.PropertyField(serializedObject.FindProperty("ScanForAlphaPixels"), new GUIContent("Scan for Alpha Pixels", "Turn on this field to scan Textures for alpha-blended pixels in order to generate transparent Materials."));
169 }
170 }
171 break;
172 case 5:
173 EditorGUILayout.PropertyField(serializedObject.FindProperty("ExternalDataMapper"), new GUIContent("External Data Mapper", "Mapper used to find data Streams on external sources."));
174 break;
175 }
176 EditorGUILayout.EndVertical();
177 serializedObject.ApplyModifiedProperties();
178 }
179 }
180}
TriLibCore.AssetLoaderOptions AssetLoaderOptions
Definition: TriLibLoader.cs:9
static void ShowInspectorGUI(SerializedObject serializedObject, ref int currentTab)