void OnPreprocessModel() { UnityEditor.ModelImporter i = (UnityEditor.ModelImporter)assetImporter; if (assetPath.Contains(PartUtility.geometryPath)) { // FIXME Should not be necessary to set when only doing Editor time modifications - but there seems to be a regression from 2019.3.3 and forwards. i.isReadable = true; i.materialImportMode = ModelImporterMaterialImportMode.None; i.importLights = false; i.importCameras = false; i.importNormals = ModelImporterNormals.Import; i.importTangents = ModelImporterTangents.CalculateMikk; i.importVisibility = false; i.importAnimatedCustomProperties = false; i.importAnimation = false; i.importBlendShapes = false; i.animationType = ModelImporterAnimationType.None; i.indexFormat = ModelImporterIndexFormat.Auto; i.meshCompression = ModelImporterMeshCompression.Medium; i.generateSecondaryUV = false; i.globalScale = 100; i.useFileScale = true; } }
private static void SetMaterialsSettings(UnityEditor.ModelImporter modelImporter, ModelImportData mid) { modelImporter.importMaterials = mid.ImportMaterials; modelImporter.materialLocation = mid.MaterialLocation; modelImporter.materialName = mid.MaterialsNaming; modelImporter.materialSearch = mid.MaterialsSearch; }
public static void ValidateMesh(Mesh mesh) { #if UNITY_EDITOR if (mesh != null) { if (!mesh.isReadable) { string path = UnityEditor.AssetDatabase.GetAssetPath(mesh); UnityEditor.ModelImporter mImporter = UnityEditor.AssetImporter.GetAtPath(path) as UnityEditor.ModelImporter; mImporter.isReadable = true; UnityEditor.AssetDatabase.ImportAsset(path, UnityEditor.ImportAssetOptions.ForceUpdate); } bool outOfRange = false; Vector2[] uv1 = mesh.uv; for (int i = uv1.Length - 1; i >= 0 && !outOfRange; i--) { Vector2 v = uv1[i]; outOfRange = (v.x < 0) || (v.x > 1f) || (v.y < 0) || (v.y > 1f); if (outOfRange) { CustomDebug.LogError("WRONG MESH UV : " + "(" + v.x + " : " + v.y + ")" + " : " + mesh.name); } } if (outOfRange) { CustomDebug.LogError("WRONG MESH UV : " + UnityEditor.AssetDatabase.GetAssetPath(mesh) + "/" + mesh.name); } } #endif }
public ModelInfo(ModelImporter mi, string path) { //获取模型数据 this.mi = mi; this.path = path; AnalyzerModel(); }
private void GenerateAnimatorIfRequired(UnityEditor.ModelImporter modelImporter, ModelImportData mid) { if (mid.AnimationsNumber == 0) { return; } var animatorGeneratorWindow = Dialog.ShowDialog <AnimatorGeneratorDialogWindow>("Animator generator", DialogType.YesNo); animatorGeneratorWindow.Initialize(modelImporter.assetPath); animatorGeneratorWindow.Yes += AnimatorGeneratorWindowOnYes; }
private void OnPreprocessModel() { if (assetPath.Contains("/MapObject/")) { UnityEditor.ModelImporter _mI = (UnityEditor.ModelImporter)assetImporter; //_mI.animationType = ModelImporterAnimationType.Legacy; _mI.tangentImportMode = ModelImporterTangentSpaceMode.Import; _mI.globalScale = 2.5f; _mI.importMaterials = false; //_mI.generateAnimations = ModelImporterGenerateAnimations.None; _mI.animationType = ModelImporterAnimationType.None; } }
public static void FillModelImportDataSettings(UnityEditor.ModelImporter modelImporter, ModelImportData mid) { var animations = modelImporter.defaultClipAnimations; for (var index = 0; index < animations.Length; index++) { if (mid.ContainsAnimation(animations[index].name)) { continue; } mid.AddAnimationData(animations[index].name, false, false); } EditorUtility.SetDirty(mid); }
public static bool CheckModeImportDataForFull(ModelImportData mid, UnityEditor.ModelImporter modelImporter) { var counter = 0; var animations = modelImporter.defaultClipAnimations; for (var index = 0; index < animations.Length; index++) { if (mid.ContainsAnimation(animations[index].name)) { counter++; } } return(counter == animations.Length); }
public static GameObject FindBestFittingRenderableGameObjectFromModelAsset(UnityEngine.Object asset, ModelImporterAnimationType animationType) { if (asset == null) { return(null); } ModelImporter modelImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(asset)) as ModelImporter; if (modelImporter == null) { return(null); } string assetPath = modelImporter.CalculateBestFittingPreviewGameObject(); GameObject gameObject = AssetDatabase.LoadMainAssetAtPath(assetPath) as GameObject; if (AvatarPreview.IsValidPreviewGameObject(gameObject, animationType)) { return(gameObject); } return(null); }
private bool HasEmbeddedMaterials() { bool result; if (this.m_Materials.arraySize == 0) { result = false; } else if (this.m_ExternalObjects.serializedObject.hasModifiedProperties) { result = this.m_HasEmbeddedMaterials; } else { this.m_HasEmbeddedMaterials = true; UnityEngine.Object[] targetObjects = this.m_ExternalObjects.serializedObject.targetObjects; for (int i = 0; i < targetObjects.Length; i++) { UnityEngine.Object @object = targetObjects[i]; ModelImporter modelImporter = @object as ModelImporter; Dictionary <AssetImporter.SourceAssetIdentifier, UnityEngine.Object> externalObjectMap = modelImporter.GetExternalObjectMap(); AssetImporter.SourceAssetIdentifier[] sourceMaterials = modelImporter.sourceMaterials; int num = 0; using (Dictionary <AssetImporter.SourceAssetIdentifier, UnityEngine.Object> .Enumerator enumerator = externalObjectMap.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <AssetImporter.SourceAssetIdentifier, UnityEngine.Object> entry = enumerator.Current; if (entry.Key.type == typeof(Material) && Array.Exists <AssetImporter.SourceAssetIdentifier>(sourceMaterials, (AssetImporter.SourceAssetIdentifier x) => x.name == entry.Key.name)) { num++; } } } this.m_HasEmbeddedMaterials = (this.m_HasEmbeddedMaterials && num != sourceMaterials.Length); } result = this.m_HasEmbeddedMaterials; } return(result); }
void ShowUpdateReferenceClip() { if (targets.Length > 1 || m_AvatarSetup.intValue == (int)ModelImporterAvatarSetup.CopyFromOther || !m_Avatar || !m_Avatar.isValid) { return; } string[] paths = new string[0]; ModelImporter importer = target as ModelImporter; if (importer.referencedClips.Length > 0) { foreach (string clipGUID in importer.referencedClips) { ArrayUtility.Add(ref paths, AssetDatabase.GUIDToAssetPath(clipGUID)); } } // Show only button if some clip reference this avatar. if (paths.Length > 0 && GUILayout.Button(Styles.UpdateReferenceClips, GUILayout.Width(150))) { foreach (string path in paths) { SetupReferencedClip(path); } try { AssetDatabase.StartAssetEditing(); foreach (string path in paths) { AssetDatabase.ImportAsset(path); } } finally { AssetDatabase.StopAssetEditing(); } } }
private void ShowUpdateReferenceClip() { if (((base.targets.Length <= 1) && (this.animationType == ModelImporterAnimationType.Human)) && !this.m_CopyAvatar.boolValue) { string[] array = new string[0]; ModelImporter target = this.target as ModelImporter; if (target.referencedClips.Length > 0) { foreach (string str in target.referencedClips) { ArrayUtility.Add <string>(ref array, AssetDatabase.GUIDToAssetPath(str)); } } if (array.Length > 0) { GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(150f) }; if (GUILayout.Button(styles.UpdateReferenceClips, options)) { foreach (string str2 in array) { this.SetupReferencedClip(str2); } try { AssetDatabase.StartAssetEditing(); foreach (string str3 in array) { AssetDatabase.ImportAsset(str3); } } finally { AssetDatabase.StopAssetEditing(); } } } } }
private void EditButtonGUI() { if (!(this.avatar == null) && this.avatar.isHuman) { string assetPath = AssetDatabase.GetAssetPath(this.avatar); ModelImporter x = AssetImporter.GetAtPath(assetPath) as ModelImporter; if (!(x == null)) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); if (GUILayout.Button(AvatarEditor.styles.editCharacter, new GUILayoutOption[] { GUILayout.Width(120f) }) && EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { this.SwitchToEditMode(); GUIUtility.ExitGUI(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } } }
internal override void PostApply() { for (int i = 0; i < base.targets.Length; i++) { if (this.oldModelSettings[i].usesOwnAvatar && !this.newModelSettings[i].usesOwnAvatar && !this.newModelSettings[i].copyAvatar) { SerializedObject serializedObject = new SerializedObject(base.targets[i]); AvatarSetupTool.ClearAll(serializedObject); serializedObject.ApplyModifiedPropertiesWithoutUndo(); } if (!this.m_CopyAvatar.boolValue && !this.newModelSettings[i].humanoid && this.rootIndex > 0) { ModelImporter modelImporter = base.targets[i] as ModelImporter; GameObject gameObject = AssetDatabase.LoadMainAssetAtPath(modelImporter.assetPath) as GameObject; Animator component = gameObject.GetComponent <Animator>(); bool flag = component && !component.hasTransformHierarchy; if (flag) { gameObject = (this.Instantiate(gameObject) as GameObject); AnimatorUtility.DeoptimizeTransformHierarchy(gameObject); } Transform transform = gameObject.transform.Find(this.m_RootMotionBoneList[this.rootIndex].text); if (transform != null) { this.m_RootMotionBoneRotation.quaternionValue = transform.rotation; } SerializedObject serializedObject2 = new SerializedObject(base.targets[i]); serializedObject2.ApplyModifiedPropertiesWithoutUndo(); if (flag) { this.DestroyImmediate(gameObject); } } if (!this.oldModelSettings[i].usesOwnAvatar && this.newModelSettings[i].usesOwnAvatar) { ModelImporter modelImporter2 = base.targets[i] as ModelImporter; if (this.oldModelSettings[i].hasNoAnimation) { ModelImporterAnimationType animationType = modelImporter2.animationType; modelImporter2.animationType = ModelImporterAnimationType.Generic; AssetDatabase.ImportAsset(modelImporter2.assetPath); modelImporter2.animationType = animationType; } SerializedObject serializedObject3 = new SerializedObject(base.targets[i]); GameObject gameObject2 = AssetDatabase.LoadMainAssetAtPath(modelImporter2.assetPath) as GameObject; Animator component2 = gameObject2.GetComponent <Animator>(); bool flag2 = component2 && !component2.hasTransformHierarchy; if (flag2) { gameObject2 = (this.Instantiate(gameObject2) as GameObject); AnimatorUtility.DeoptimizeTransformHierarchy(gameObject2); } AvatarSetupTool.AutoSetupOnInstance(gameObject2, serializedObject3); this.m_IsBiped = AvatarBipedMapper.IsBiped(gameObject2.transform, this.m_BipedMappingReport); if (flag2) { this.DestroyImmediate(gameObject2); } serializedObject3.ApplyModifiedPropertiesWithoutUndo(); } } this.oldModelSettings = null; this.newModelSettings = null; }
private extern static void INTERNAL_set_extraUserProperties([Writable, NotNull("NullExceptionObject")] ModelImporter self, string[] value);
private void NormalsAndTangentsGUI() { GUILayout.Label(ModelImporterModelEditor.styles.TangentSpace, EditorStyles.boldLabel, new GUILayoutOption[0]); bool flag = true; UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { ModelImporter modelImporter = (ModelImporter)targets[i]; if (!modelImporter.isTangentImportSupported) { flag = false; } } EditorGUI.BeginChangeCheck(); EditorGUILayout.Popup(this.m_NormalImportMode, ModelImporterModelEditor.styles.NormalModeLabelsAll, ModelImporterModelEditor.styles.TangentSpaceNormalLabel, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (this.m_NormalImportMode.intValue == 2) { this.m_TangentImportMode.intValue = 2; } else if (this.m_NormalImportMode.intValue == 0 && flag) { this.m_TangentImportMode.intValue = 0; } else { this.m_TangentImportMode.intValue = 3; } } using (new EditorGUI.DisabledScope(this.m_NormalImportMode.intValue != 1)) { EditorGUILayout.Popup(this.m_NormalCalculationMode, ModelImporterModelEditor.styles.RecalculateNormalsOpt, ModelImporterModelEditor.styles.RecalculateNormalsLabel, new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); EditorGUILayout.Slider(this.m_NormalSmoothAngle, 0f, 180f, ModelImporterModelEditor.styles.SmoothingAngle, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_NormalSmoothAngle.floatValue = Mathf.Round(this.m_NormalSmoothAngle.floatValue); } } GUIContent[] displayedOptions = ModelImporterModelEditor.styles.TangentSpaceModeOptLabelsAll; ModelImporterTangents[] array = ModelImporterModelEditor.styles.TangentSpaceModeOptEnumsAll; if (this.m_NormalImportMode.intValue == 1 || !flag) { displayedOptions = ModelImporterModelEditor.styles.TangentSpaceModeOptLabelsCalculate; array = ModelImporterModelEditor.styles.TangentSpaceModeOptEnumsCalculate; } else if (this.m_NormalImportMode.intValue == 2) { displayedOptions = ModelImporterModelEditor.styles.TangentSpaceModeOptLabelsNone; array = ModelImporterModelEditor.styles.TangentSpaceModeOptEnumsNone; } using (new EditorGUI.DisabledScope(this.m_NormalImportMode.intValue == 2)) { int num = Array.IndexOf <ModelImporterTangents>(array, (ModelImporterTangents)this.m_TangentImportMode.intValue); EditorGUI.BeginChangeCheck(); num = EditorGUILayout.Popup(ModelImporterModelEditor.styles.TangentSpaceTangentLabel, num, displayedOptions, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_TangentImportMode.intValue = (int)array[num]; } } }
public override void OnInspectorGUI() { if (ModelImporterModelEditor.styles == null) { ModelImporterModelEditor.styles = new ModelImporterModelEditor.Styles(); } GUILayout.Label(ModelImporterModelEditor.styles.Meshes, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_GlobalScale, ModelImporterModelEditor.styles.ScaleFactor, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_FileScale, ModelImporterModelEditor.styles.FileScaleFactor, new GUILayoutOption[0]); EditorGUILayout.Popup(this.m_MeshCompression, ModelImporterModelEditor.styles.MeshCompressionOpt, ModelImporterModelEditor.styles.MeshCompressionLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_IsReadable, ModelImporterModelEditor.styles.IsReadable, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_OptimizeMeshForGPU, ModelImporterModelEditor.styles.OptimizeMeshForGPU, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ImportBlendShapes, ModelImporterModelEditor.styles.ImportBlendShapes, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AddColliders, ModelImporterModelEditor.styles.GenerateColliders, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_SwapUVChannels, ModelImporterModelEditor.styles.SwapUVChannels, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_GenerateSecondaryUV, ModelImporterModelEditor.styles.GenerateSecondaryUV, new GUILayoutOption[0]); if (this.m_GenerateSecondaryUV.boolValue) { EditorGUI.indentLevel++; this.m_SecondaryUVAdvancedOptions = EditorGUILayout.Foldout(this.m_SecondaryUVAdvancedOptions, ModelImporterModelEditor.styles.GenerateSecondaryUVAdvanced, EditorStyles.foldout); if (this.m_SecondaryUVAdvancedOptions) { EditorGUI.BeginChangeCheck(); EditorGUILayout.Slider(this.m_SecondaryUVHardAngle, 0f, 180f, ModelImporterModelEditor.styles.secondaryUVHardAngle, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_SecondaryUVPackMargin, 1f, 64f, ModelImporterModelEditor.styles.secondaryUVPackMargin, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_SecondaryUVAngleDistortion, 1f, 75f, ModelImporterModelEditor.styles.secondaryUVAngleDistortion, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_SecondaryUVAreaDistortion, 1f, 75f, ModelImporterModelEditor.styles.secondaryUVAreaDistortion, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_SecondaryUVHardAngle.floatValue = Mathf.Round(this.m_SecondaryUVHardAngle.floatValue); this.m_SecondaryUVPackMargin.floatValue = Mathf.Round(this.m_SecondaryUVPackMargin.floatValue); this.m_SecondaryUVAngleDistortion.floatValue = Mathf.Round(this.m_SecondaryUVAngleDistortion.floatValue); this.m_SecondaryUVAreaDistortion.floatValue = Mathf.Round(this.m_SecondaryUVAreaDistortion.floatValue); } } EditorGUI.indentLevel--; } GUILayout.Label(ModelImporterModelEditor.styles.TangentSpace, EditorStyles.boldLabel, new GUILayoutOption[0]); bool flag = true; UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { ModelImporter modelImporter = (ModelImporter)targets[i]; if (!modelImporter.isTangentImportSupported) { flag = false; } } EditorGUI.BeginChangeCheck(); EditorGUILayout.Popup(this.m_NormalImportMode, ModelImporterModelEditor.styles.TangentSpaceModeOptLabelsAll, ModelImporterModelEditor.styles.TangentSpaceNormalLabel, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_TangentImportMode.intValue = this.m_NormalImportMode.intValue; if (!flag && this.m_TangentImportMode.intValue == 0) { this.m_TangentImportMode.intValue = 1; } } GUIContent[] displayedOptions = ModelImporterModelEditor.styles.TangentSpaceModeOptLabelsAll; ModelImporterTangentSpaceMode[] array = ModelImporterModelEditor.styles.TangentSpaceModeOptEnumsAll; if (this.m_NormalImportMode.intValue == 1 || !flag) { displayedOptions = ModelImporterModelEditor.styles.TangentSpaceModeOptLabelsCalculate; array = ModelImporterModelEditor.styles.TangentSpaceModeOptEnumsCalculate; } else { if (this.m_NormalImportMode.intValue == 2) { displayedOptions = ModelImporterModelEditor.styles.TangentSpaceModeOptLabelsNone; array = ModelImporterModelEditor.styles.TangentSpaceModeOptEnumsNone; } } EditorGUI.BeginDisabledGroup(this.m_NormalImportMode.intValue == 2); int num = Array.IndexOf <ModelImporterTangentSpaceMode>(array, (ModelImporterTangentSpaceMode)this.m_TangentImportMode.intValue); EditorGUI.BeginChangeCheck(); num = EditorGUILayout.Popup(ModelImporterModelEditor.styles.TangentSpaceTangentLabel, num, displayedOptions, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_TangentImportMode.intValue = (int)array[num]; } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(this.m_NormalImportMode.intValue != 1); EditorGUI.BeginChangeCheck(); EditorGUILayout.Slider(this.m_NormalSmoothAngle, 0f, 180f, ModelImporterModelEditor.styles.SmoothingAngle, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_NormalSmoothAngle.floatValue = Mathf.Round(this.m_NormalSmoothAngle.floatValue); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(this.m_TangentImportMode.intValue != 1); EditorGUILayout.PropertyField(this.m_SplitTangentsAcrossSeams, ModelImporterModelEditor.styles.SplitTangents, new GUILayoutOption[0]); EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(this.m_KeepQuads, ModelImporterModelEditor.styles.KeepQuads, new GUILayoutOption[0]); GUILayout.Label(ModelImporterModelEditor.styles.Materials, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ImportMaterials, ModelImporterModelEditor.styles.ImportMaterials, new GUILayoutOption[0]); string text; if (this.m_ImportMaterials.boolValue) { EditorGUILayout.Popup(this.m_MaterialName, (!this.m_ShowAllMaterialNameOptions) ? ModelImporterModelEditor.styles.MaterialNameOptMain : ModelImporterModelEditor.styles.MaterialNameOptAll, ModelImporterModelEditor.styles.MaterialName, new GUILayoutOption[0]); EditorGUILayout.Popup(this.m_MaterialSearch, ModelImporterModelEditor.styles.MaterialSearchOpt, ModelImporterModelEditor.styles.MaterialSearch, new GUILayoutOption[0]); text = string.Concat(new string[] { ModelImporterModelEditor.styles.MaterialHelpStart.text.Replace("%MAT%", ModelImporterModelEditor.styles.MaterialNameHelp[this.m_MaterialName.intValue].text), "\n", ModelImporterModelEditor.styles.MaterialSearchHelp[this.m_MaterialSearch.intValue].text, "\n", ModelImporterModelEditor.styles.MaterialHelpEnd.text }); } else { text = ModelImporterModelEditor.styles.MaterialHelpDefault.text; } GUILayout.Label(new GUIContent(text), EditorStyles.helpBox, new GUILayoutOption[0]); base.ApplyRevertGUI(); }
private void fbxCreatePrefab(FBXInfo fbxInfo) { DirectoryInfo info = new DirectoryInfo(fbxInfo.rawFolder); List <string> fbxsList = new List <string>(); if (Directory.Exists(fbxInfo.fbxFolder) == false) { Directory.CreateDirectory(fbxInfo.fbxFolder); } if (Directory.Exists(fbxInfo.prefabFolder) == false) { Directory.CreateDirectory(fbxInfo.prefabFolder); } bool hasModel = false; foreach (FileInfo fileInfo in info.GetFiles()) { if (fileInfo.Extension.ToUpper() == ".FBX") { string fbxName = fileInfo.Name; string fbxPath; if (fbxName == fbxInfo.fileName + fileInfo.Extension) { hasModel = true; fbxPath = fbxInfo.fbxFolder + fbxName; fileInfo.CopyTo(fbxPath, true); continue; } if (fbxInfo.type == FBXType.MODEL) { continue; } if (fileInfo.Name.IndexOf(fbxInfo.fileName + "@") == -1) { fbxName = fbxInfo.fileName + "@" + fbxName; } fbxPath = fbxInfo.fbxFolder + fbxName; fileInfo.CopyTo(fbxPath, true); fbxsList.Add(fbxName); } else { fileInfo.CopyTo(fbxInfo.fbxFolder + fileInfo.Name, true); } } string prefabFbxName = fbxInfo.fileName + ".fbx"; if (hasModel == false) { if (fbxsList.Count == 0) { ShowNotification(new GUIContent("不存在文件")); return; } string prefabCopyFBX = fbxInfo.fbxFolder + fbxsList[0]; string prefabFBX = fbxInfo.fbxFolder + prefabFbxName; File.Copy(prefabCopyFBX, prefabFBX, true); fbxsList.Add(prefabFbxName); } else { fbxsList.Add(prefabFbxName); } loopAnimationClipNames = EditorConfigUtils.LoopAnimationClipNames; AssetDatabase.Refresh(); List <AnimationClip> animationClipList = new List <AnimationClip>(); foreach (string fbxName in fbxsList) { string fbxPath = fbxInfo.fbxFolder + fbxName; ModelImporter assetImporter = AssetImporter.GetAtPath(fbxPath) as ModelImporter; if (assetImporter == null) { continue; } bool isHuman = fbxInfo.animationType == ModelImporterAnimationType.Human; assetImporter.animationType = fbxInfo.animationType; if (prefabFbxName == fbxName) { assetImporter.importAnimation = false; } else { assetImporter.importAnimation = true; ModelImporterClipAnimation[] clipAnimations = assetImporter.defaultClipAnimations; foreach (ModelImporterClipAnimation modelImporterClipAnimation in clipAnimations) { if (loopAnimationClipNames.Contains(modelImporterClipAnimation.name)) { modelImporterClipAnimation.loop = true; modelImporterClipAnimation.wrapMode = WrapMode.Loop; } } } assetImporter.SaveAndReimport(); if (assetImporter.importAnimation) { AnimationClip clip = AssetDatabase.LoadAssetAtPath <AnimationClip>(fbxPath); animationClipList.Add(clip); } } GameObject fbxRawModel = AssetDatabase.LoadAssetAtPath <GameObject>(fbxInfo.fbxFolder + prefabFbxName); if (fbxRawModel == null) { ShowNotification(new GUIContent("模型文件不存在")); return; } string prefabPath = fbxInfo.prefabPath; GameObject fbxPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath); if (fbxPrefab == null) { fbxPrefab = PrefabUtility.SaveAsPrefabAsset(fbxRawModel, prefabPath); } else { ///已经存在了的 PrefabCopy2Utility prefabCopyUtility = new PrefabCopy2Utility(); //PrefabCopyUtility prefabCopyUtility = new PrefabCopyUtility(); fbxPrefab = prefabCopyUtility.replace(fbxPrefab, fbxRawModel); } if (fbxInfo.animationType != ModelImporterAnimationType.Legacy) { Animation animation = fbxPrefab.GetComponent <Animation>(); if (animation != null) { GameObject.DestroyImmediate(animation, true); } Animator animator = fbxPrefab.GetComponent <Animator>(); if (animationClipList.Count > 0) { if (animator == null) { animator = fbxPrefab.AddComponent <Animator>(); } string controllerFullPath = string.Format("{0}default.controller", fbxInfo.fbxFolder); AnimatorController animatorController = AssetDatabase.LoadAssetAtPath <AnimatorController>(controllerFullPath); if (animatorController == null) { animatorController = AnimatorController.CreateAnimatorControllerAtPath(controllerFullPath); } if (animatorController.layers.Length == 0) { animatorController.AddLayer("Base Layer"); } AnimatorControllerLayer animatorControllerLayer = animatorController.layers[0]; AnimatorState defaultState = animatorControllerLayer.stateMachine.defaultState; foreach (AnimationClip clip in animationClipList) { //需要重新加载不然会崩溃 AnimatorState state = AnimatorControllerCreater.addNoExistState(animatorControllerLayer, clip); if (state != null && defaultState == null) { if (state.name.IndexOf("idle") == 0) { defaultState = state; animatorControllerLayer.stateMachine.defaultState = defaultState; } } } if (animator.runtimeAnimatorController == null) { animator.runtimeAnimatorController = animatorController; } AnimatorClipRef animatiorClipRef = fbxPrefab.GetComponent <AnimatorClipRef>(); if (animatiorClipRef == null) { animatiorClipRef = fbxPrefab.AddComponent <AnimatorClipRef>(); } animatiorClipRef.animationClips = animationClipList.ToArray(); } else if (animator != null) { AnimatorClipRef animatiorClipRef = fbxPrefab.GetComponent <AnimatorClipRef>(); if (animatiorClipRef == null) { GameObject.DestroyImmediate(animator, true); } } } else { Animation animation = fbxPrefab.GetComponent <Animation>(); if (animationClipList.Count > 0) { if (animation == null) { animation = fbxPrefab.AddComponent <Animation>(); } AnimationUtility.SetAnimationClips(animation, animationClipList.ToArray()); } else { if (animation != null) { GameObject.DestroyImmediate(animation, true); } } } UnitCFG cfg = fbxPrefab.GetComponent <UnitCFG>(); if (cfg == null) { cfg = fbxPrefab.AddComponent <UnitCFG>(); } EditorUtility.SetDirty(fbxPrefab); viewPrefab(fbxPrefab); AssetDatabase.Refresh(); }
private extern static void INTERNAL_set_extraExposedTransformPaths([Writable] ModelImporter self, string[] value);
private extern static ModelImporterClipAnimation[] GetDefaultClipAnimations(ModelImporter self);
private extern static void SetClipAnimations([Writable, NotNull("NullExceptionObject")] ModelImporter self, ModelImporterClipAnimation[] value);
/// <summary> /// Sets the name of the root motion bone. /// </summary> /// <param name="imp">Imp.</param> /// <param name="szValue">Size value.</param> public static void ApplyRootMotionBoneName(ModelImporter imp, string szValue) { SerializedObject impSO = new SerializedObject(imp); SerializedProperty rootMotion = impSO.FindProperty(PType.m_HumanDescription.ToString()).FindPropertyRelative(PType.m_RootMotionBoneName.ToString()); rootMotion.stringValue = szValue; SerializedProperty type = impSO.FindProperty(PType.m_AnimationType.ToString()); type.enumValueIndex = 2; impSO.ApplyModifiedProperties(); impSO.Dispose(); }
private void ImportAvatarReference() { EditorGUI.BeginChangeCheck(); this.m_RefAvatar = (EditorGUILayout.ObjectField("Use skeleton from", this.m_RefAvatar, typeof(Avatar), true, new GUILayoutOption[0]) as Avatar); if (EditorGUI.EndChangeCheck()) { this.m_RefImporter = (AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(this.m_RefAvatar)) as ModelImporter); } if (this.m_RefImporter != null && GUILayout.Button("Import skeleton", new GUILayoutOption[0])) { AvatarMaskUtility.UpdateTransformMask(this.target as AvatarMask, this.m_RefImporter.transformPaths, null); } }
private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter) { SerializedObject serializedObject = new SerializedObject(new UnityEngine.Object[2]{ (UnityEngine.Object) importer, (UnityEngine.Object) otherImporter }); bool flag = !serializedObject.FindProperty("m_HumanDescription").hasMultipleDifferentValues; serializedObject.Dispose(); return flag; }
private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter) { UnityEngine.Object[] objs = new UnityEngine.Object[] { importer, otherImporter }; SerializedObject obj2 = new SerializedObject(objs); bool flag = !obj2.FindProperty("m_HumanDescription").hasMultipleDifferentValues; obj2.Dispose(); return flag; }
private extern static void SetSourceAvatarInternal(ModelImporter self, Avatar value);
private void ImportAvatarReference() { EditorGUI.BeginChangeCheck(); this.m_RefAvatar = EditorGUILayout.ObjectField("Use skeleton from", (UnityEngine.Object) this.m_RefAvatar, typeof (Avatar), true, new GUILayoutOption[0]) as Avatar; if (EditorGUI.EndChangeCheck()) this.m_RefImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath((UnityEngine.Object) this.m_RefAvatar)) as ModelImporter; if (!((UnityEngine.Object) this.m_RefImporter != (UnityEngine.Object) null) || !GUILayout.Button("Import skeleton")) return; AvatarMaskUtility.UpdateTransformMask(this.m_TransformMask, this.m_RefImporter.transformPaths, (string[]) null); }
private extern static void SetClipAnimations([Writable] ModelImporter self, ModelImporterClipAnimation[] value);
internal override void PostApply() { // But we might not be done yet! // For all models which did not have own humanoid before but should have it now, // we need to perform auto-mapping. (For the opposite case we also need to clear the mapping.) // Iterate through all the models... for (int i = 0; i < targets.Length; i++) { // If this model had its own humanoid avatar before but shouldn't have it now... if (oldModelSettings[i].usesOwnAvatar && !newModelSettings[i].usesOwnAvatar && !newModelSettings[i].copyAvatar) { // ...then clear auto-setup on this model. SerializedObject so = new SerializedObject(targets[i]); AvatarSetupTool.ClearAll(so); so.ApplyModifiedPropertiesWithoutUndo(); } if (!m_CopyAvatar.boolValue && !newModelSettings[i].humanoid && rootIndex > 0) { ModelImporter importer = targets[i] as ModelImporter; GameObject go = AssetDatabase.LoadMainAssetAtPath(importer.assetPath) as GameObject; // The character could be optimized right now // 'm_OptimizeGameObjects' can't be used to tell if it is optimized, because the user can change this value from UI, // and the change hasn't been applied yet. Animator animator = go.GetComponent <Animator>(); bool noTransformHierarchy = animator && !animator.hasTransformHierarchy; if (noTransformHierarchy) { go = Instantiate(go) as GameObject; AnimatorUtility.DeoptimizeTransformHierarchy(go); } SerializedObject so = new SerializedObject(targets[i]); so.ApplyModifiedPropertiesWithoutUndo(); if (noTransformHierarchy) { DestroyImmediate(go); } } // If this model should have its own humanoid avatar before and didn't have it before, // then we need to perform auto-mapping. if (!oldModelSettings[i].usesOwnAvatar && newModelSettings[i].usesOwnAvatar) { ModelImporter importer = targets[i] as ModelImporter; // Special case if the model didn't have animation before... if (oldModelSettings[i].hasNoAnimation && assetTargets[i] != null) { // We have to do an extra import first, before the automapping works. // Because the model doesn't have any skinned meshes when it was last imported with // Animation Mode: None. And the auro-mapping relies on information in the skinned meshes. var targetAnimationType = importer.animationType; importer.animationType = ModelImporterAnimationType.Generic; // we dont want to build humanoid here, since it will generate errors. AssetDatabase.ImportAsset(importer.assetPath); importer.animationType = targetAnimationType; } // Perform auto-setup on this model. SerializedObject so = new SerializedObject(targets[i]); GameObject go = assetTargets[i] as GameObject; // The character could be optimized right now // 'm_OptimizeGameObjects' can't be used to tell if it is optimized, because the user can change this value from UI, // and the change hasn't been applied yet. if (go != null) { Animator animator = go.GetComponent <Animator>(); bool noTransformHierarchy = animator && !animator.hasTransformHierarchy; if (noTransformHierarchy) { go = Instantiate(go) as GameObject; AnimatorUtility.DeoptimizeTransformHierarchy(go); } AvatarSetupTool.AutoSetupOnInstance(go, so); m_IsBiped = AvatarBipedMapper.IsBiped(go.transform, m_BipedMappingReport); if (noTransformHierarchy) { DestroyImmediate(go); } } so.ApplyModifiedPropertiesWithoutUndo(); } } oldModelSettings = null; newModelSettings = null; }
private extern static string[] INTERNAL_GetReferencedClips(ModelImporter self);
internal override void Apply() { ModelImporterRigEditor.MappingRelevantSettings[] array = new ModelImporterRigEditor.MappingRelevantSettings[base.targets.Length]; for (int i = 0; i < base.targets.Length; i++) { SerializedObject serializedObject = new SerializedObject(base.targets[i]); SerializedProperty serializedProperty = serializedObject.FindProperty("m_AnimationType"); SerializedProperty serializedProperty2 = serializedObject.FindProperty("m_CopyAvatar"); array[i].humanoid = (serializedProperty.intValue == 3); array[i].hasNoAnimation = (serializedProperty.intValue == 0); array[i].copyAvatar = serializedProperty2.boolValue; } ModelImporterRigEditor.MappingRelevantSettings[] array2 = new ModelImporterRigEditor.MappingRelevantSettings[base.targets.Length]; Array.Copy(array, array2, base.targets.Length); for (int j = 0; j < base.targets.Length; j++) { if (!this.m_AnimationType.hasMultipleDifferentValues) { array2[j].humanoid = (this.m_AnimationType.intValue == 3); } if (!this.m_CopyAvatar.hasMultipleDifferentValues) { array2[j].copyAvatar = this.m_CopyAvatar.boolValue; } } base.Apply(); for (int k = 0; k < base.targets.Length; k++) { if (array[k].usesOwnAvatar && !array2[k].usesOwnAvatar && !array2[k].copyAvatar) { SerializedObject serializedObject2 = new SerializedObject(base.targets[k]); AvatarSetupTool.ClearAll(serializedObject2); serializedObject2.ApplyModifiedPropertiesWithoutUndo(); } if (!this.m_CopyAvatar.boolValue && !array2[k].humanoid && this.rootIndex > 0) { ModelImporter modelImporter = base.targets[k] as ModelImporter; GameObject gameObject = AssetDatabase.LoadMainAssetAtPath(modelImporter.assetPath) as GameObject; Animator component = gameObject.GetComponent <Animator>(); bool flag = component && !component.hasTransformHierarchy; if (flag) { gameObject = UnityEngine.Object.Instantiate <GameObject>(gameObject); AnimatorUtility.DeoptimizeTransformHierarchy(gameObject); } Transform transform = gameObject.transform.Find(this.m_RootMotionBoneList[this.rootIndex].text); if (transform != null) { this.m_RootMotionBoneRotation.quaternionValue = transform.rotation; } SerializedObject serializedObject3 = new SerializedObject(base.targets[k]); serializedObject3.ApplyModifiedPropertiesWithoutUndo(); if (flag) { UnityEngine.Object.DestroyImmediate(gameObject); } } if (!array[k].usesOwnAvatar && array2[k].usesOwnAvatar) { ModelImporter modelImporter2 = base.targets[k] as ModelImporter; if (array[k].hasNoAnimation) { ModelImporterAnimationType animationType = modelImporter2.animationType; modelImporter2.animationType = ModelImporterAnimationType.Generic; AssetDatabase.ImportAsset(modelImporter2.assetPath); modelImporter2.animationType = animationType; } SerializedObject serializedObject4 = new SerializedObject(base.targets[k]); GameObject gameObject2 = AssetDatabase.LoadMainAssetAtPath(modelImporter2.assetPath) as GameObject; Animator component2 = gameObject2.GetComponent <Animator>(); bool flag2 = component2 && !component2.hasTransformHierarchy; if (flag2) { gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject2); AnimatorUtility.DeoptimizeTransformHierarchy(gameObject2); } AvatarSetupTool.AutoSetupOnInstance(gameObject2, serializedObject4); this.m_IsBiped = AvatarBipedMapper.IsBiped(gameObject2.transform, this.m_BipedMappingReport); if (flag2) { UnityEngine.Object.DestroyImmediate(gameObject2); } serializedObject4.ApplyModifiedPropertiesWithoutUndo(); } } }
private extern static void INTERNAL_set_extraUserProperties([Writable] ModelImporter self, string[] value);
public static void SetModelImporterImportSettings(UnityEditor.ModelImporter modelImporter, ModelImportData mid) { modelImporter.clipAnimations = GetImportedAnimationClips(modelImporter.defaultClipAnimations, mid); SetModelSettings(modelImporter, mid); SetMaterialsSettings(modelImporter, mid); }
public static bool IsSameModelSetting (ModelImporter target, ModelImporter compareBase) { if (target.addCollider != compareBase.addCollider) return false; if (target.animationCompression != compareBase.animationCompression) return false; if (target.animationPositionError != compareBase.animationPositionError) return false; if (target.animationRotationError != compareBase.animationRotationError) return false; if (target.animationScaleError != compareBase.animationScaleError) return false; if (target.animationType != compareBase.animationType) return false; if (target.animationWrapMode != compareBase.animationWrapMode) return false; if (target.bakeIK != compareBase.bakeIK) return false; // clipAnimations { if (target.clipAnimations.Length != compareBase.clipAnimations.Length) return false; for (int i = 0; i < target.clipAnimations.Length; i++) { if (target.clipAnimations[i].curves != compareBase.clipAnimations[i].curves) return false; if (target.clipAnimations[i].cycleOffset != compareBase.clipAnimations[i].cycleOffset) return false; if (target.clipAnimations[i].events != compareBase.clipAnimations[i].events) return false; if (target.clipAnimations[i].firstFrame != compareBase.clipAnimations[i].firstFrame) return false; if (target.clipAnimations[i].heightFromFeet != compareBase.clipAnimations[i].heightFromFeet) return false; if (target.clipAnimations[i].heightOffset != compareBase.clipAnimations[i].heightOffset) return false; if (target.clipAnimations[i].keepOriginalOrientation != compareBase.clipAnimations[i].keepOriginalOrientation) return false; if (target.clipAnimations[i].keepOriginalPositionXZ != compareBase.clipAnimations[i].keepOriginalPositionXZ) return false; if (target.clipAnimations[i].keepOriginalPositionY != compareBase.clipAnimations[i].keepOriginalPositionY) return false; if (target.clipAnimations[i].lastFrame != compareBase.clipAnimations[i].lastFrame) return false; if (target.clipAnimations[i].lockRootHeightY != compareBase.clipAnimations[i].lockRootHeightY) return false; if (target.clipAnimations[i].lockRootPositionXZ != compareBase.clipAnimations[i].lockRootPositionXZ) return false; if (target.clipAnimations[i].lockRootRotation != compareBase.clipAnimations[i].lockRootRotation) return false; if (target.clipAnimations[i].loop != compareBase.clipAnimations[i].loop) return false; if (target.clipAnimations[i].loopPose != compareBase.clipAnimations[i].loopPose) return false; if (target.clipAnimations[i].loopTime != compareBase.clipAnimations[i].loopTime) return false; if (target.clipAnimations[i].maskNeedsUpdating != compareBase.clipAnimations[i].maskNeedsUpdating) return false; if (target.clipAnimations[i].maskSource != compareBase.clipAnimations[i].maskSource) return false; if (target.clipAnimations[i].maskType != compareBase.clipAnimations[i].maskType) return false; if (target.clipAnimations[i].mirror != compareBase.clipAnimations[i].mirror) return false; if (target.clipAnimations[i].name != compareBase.clipAnimations[i].name) return false; if (target.clipAnimations[i].rotationOffset != compareBase.clipAnimations[i].rotationOffset) return false; if (target.clipAnimations[i].takeName != compareBase.clipAnimations[i].takeName) return false; if (target.clipAnimations[i].wrapMode != compareBase.clipAnimations[i].wrapMode) return false; } } // if (target.defaultClipAnimations != compareBase.defaultClipAnimations) return false; // extraExposedTransformPaths { if (target.extraExposedTransformPaths.Length != compareBase.extraExposedTransformPaths.Length) return false; for (int i = 0; i < target.extraExposedTransformPaths.Length; i++) { if (target.extraExposedTransformPaths[i] != compareBase.extraExposedTransformPaths[i]) return false; } } // if (target.fileScale != compareBase.fileScale) return false; if (target.generateAnimations != compareBase.generateAnimations) return false; if (target.generateSecondaryUV != compareBase.generateSecondaryUV) return false; if (target.globalScale != compareBase.globalScale) return false; // humanDescription { if (target.humanDescription.armStretch != compareBase.humanDescription.armStretch) return false; if (target.humanDescription.feetSpacing != compareBase.humanDescription.feetSpacing) return false; // human { if (target.humanDescription.human.Length != compareBase.humanDescription.human.Length) return false; for (int i = 0; i < target.humanDescription.human.Length; i++) { if (target.humanDescription.human[i].boneName != compareBase.humanDescription.human[i].boneName) return false; if (target.humanDescription.human[i].humanName != compareBase.humanDescription.human[i].humanName) return false; // limit if (target.humanDescription.human[i].limit.axisLength != compareBase.humanDescription.human[i].limit.axisLength) return false; if (target.humanDescription.human[i].limit.center != compareBase.humanDescription.human[i].limit.center) return false; if (target.humanDescription.human[i].limit.max != compareBase.humanDescription.human[i].limit.max) return false; if (target.humanDescription.human[i].limit.min != compareBase.humanDescription.human[i].limit.min) return false; if (target.humanDescription.human[i].limit.useDefaultValues != compareBase.humanDescription.human[i].limit.useDefaultValues) return false; } } if (target.humanDescription.legStretch != compareBase.humanDescription.legStretch) return false; if (target.humanDescription.lowerArmTwist != compareBase.humanDescription.lowerArmTwist) return false; if (target.humanDescription.lowerLegTwist != compareBase.humanDescription.lowerLegTwist) return false; // skeleton { if (target.humanDescription.skeleton.Length != compareBase.humanDescription.skeleton.Length) return false; for (int i = 0; i < target.humanDescription.skeleton.Length; i++) { if (target.humanDescription.skeleton[i].name != compareBase.humanDescription.skeleton[i].name) return false; if (target.humanDescription.skeleton[i].position != compareBase.humanDescription.skeleton[i].position) return false; if (target.humanDescription.skeleton[i].rotation != compareBase.humanDescription.skeleton[i].rotation) return false; if (target.humanDescription.skeleton[i].scale != compareBase.humanDescription.skeleton[i].scale) return false; } } if (target.humanDescription.upperArmTwist != compareBase.humanDescription.upperArmTwist) return false; if (target.humanDescription.upperLegTwist != compareBase.humanDescription.upperLegTwist) return false; } if (target.importAnimation != compareBase.importAnimation) return false; if (target.importBlendShapes != compareBase.importBlendShapes) return false; // if (target.importedTakeInfos != compareBase.importedTakeInfos) return false; if (target.importMaterials != compareBase.importMaterials) return false; // if (target.isBakeIKSupported != compareBase.isBakeIKSupported) return false; // if (target.isFileScaleUsed != compareBase.isFileScaleUsed) return false; if (target.isReadable != compareBase.isReadable) return false; // if (target.isTangentImportSupported != compareBase.isTangentImportSupported) return false; // if (target.isUseFileUnitsSupported != compareBase.isUseFileUnitsSupported) return false; if (target.materialName != compareBase.materialName) return false; if (target.materialSearch != compareBase.materialSearch) return false; if (target.meshCompression != compareBase.meshCompression) return false; if (target.motionNodeName != compareBase.motionNodeName) return false; if (target.normalImportMode != compareBase.normalImportMode) return false; if (target.normalSmoothingAngle != compareBase.normalSmoothingAngle) return false; if (target.optimizeGameObjects != compareBase.optimizeGameObjects) return false; if (target.optimizeMesh != compareBase.optimizeMesh) return false; // if (target.referencedClips != compareBase.referencedClips) return false; if (target.secondaryUVAngleDistortion != compareBase.secondaryUVAngleDistortion) return false; if (target.secondaryUVAreaDistortion != compareBase.secondaryUVAreaDistortion) return false; if (target.secondaryUVHardAngle != compareBase.secondaryUVHardAngle) return false; if (target.secondaryUVPackMargin != compareBase.secondaryUVPackMargin) return false; if (target.sourceAvatar != compareBase.sourceAvatar) return false; if (target.splitTangentsAcrossSeams != compareBase.splitTangentsAcrossSeams) return false; if (target.swapUVChannels != compareBase.swapUVChannels) return false; if (target.tangentImportMode != compareBase.tangentImportMode) return false; // if (target.transformPaths != compareBase.transformPaths) return false; if (target.useFileUnits != compareBase.useFileUnits) return false; return true; }
private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter) { SerializedObject serializedObject = new SerializedObject(new UnityEngine.Object[] { importer, otherImporter }); SerializedProperty serializedProperty = serializedObject.FindProperty("m_HumanDescription"); bool result = !serializedProperty.hasMultipleDifferentValues; serializedObject.Dispose(); return result; }
private void OverwriteImportSettings(ModelImporter importer) { var reference = referenceImporter as ModelImporter; UnityEngine.Assertions.Assert.IsNotNull(reference); importer.addCollider = reference.addCollider; importer.animationCompression = reference.animationCompression; importer.animationPositionError = reference.animationPositionError; importer.animationRotationError = reference.animationRotationError; importer.animationScaleError = reference.animationScaleError; importer.animationType = reference.animationType; importer.animationWrapMode = reference.animationWrapMode; importer.bakeIK = reference.bakeIK; importer.clipAnimations = reference.clipAnimations; // importer.defaultClipAnimations = reference.defaultClipAnimations; importer.extraExposedTransformPaths = reference.extraExposedTransformPaths; // importer.fileScale = reference.fileScale; importer.generateAnimations = reference.generateAnimations; importer.generateSecondaryUV = reference.generateSecondaryUV; importer.globalScale = reference.globalScale; importer.humanDescription = reference.humanDescription; importer.importAnimation = reference.importAnimation; importer.importBlendShapes = reference.importBlendShapes; // importer.importedTakeInfos = reference.importedTakeInfos; importer.importMaterials = reference.importMaterials; // importer.isBakeIKSupported = reference.isBakeIKSupported; // importer.isFileScaleUsed = reference.isFileScaleUsed; importer.isReadable = reference.isReadable; // importer.isTangentImportSupported = reference.isTangentImportSupported; // importer.isUseFileUnitsSupported = reference.isUseFileUnitsSupported; importer.materialName = reference.materialName; importer.materialSearch = reference.materialSearch; importer.meshCompression = reference.meshCompression; importer.motionNodeName = reference.motionNodeName; importer.importNormals = reference.importNormals; importer.normalSmoothingAngle = reference.normalSmoothingAngle; importer.optimizeGameObjects = reference.optimizeGameObjects; importer.optimizeMesh = reference.optimizeMesh; // importer.referencedClips = reference.referencedClips; importer.secondaryUVAngleDistortion = reference.secondaryUVAngleDistortion; importer.secondaryUVAreaDistortion = reference.secondaryUVAreaDistortion; importer.secondaryUVHardAngle = reference.secondaryUVHardAngle; importer.secondaryUVPackMargin = reference.secondaryUVPackMargin; importer.sourceAvatar = reference.sourceAvatar; importer.swapUVChannels = reference.swapUVChannels; importer.importTangents = reference.importTangents; // importer.transformPaths = reference.transformPaths; importer.useFileUnits = reference.useFileUnits; }
private static extern ModelImporterClipAnimation[] GetClipAnimations(ModelImporter self);
public void Initialize(UnityEditor.ModelImporter modelImporter, ModelImportData mid, string modelPath) { ModelPath = modelPath; _modelImporter = modelImporter; _modelImportData = mid; }
private extern static void INTERNAL_set_extraExposedTransformPaths([Writable, NotNull("NullExceptionObject")] ModelImporter self, string[] value);
public void ForceOnPreprocessModel(ModelImporter importer) { if (importerSourceObj == null) return; var importerSource = importerSourceObj as ModelImporter; if (importerSource == null) return; importer.addCollider = importerSource.addCollider; importer.animationCompression = importerSource.animationCompression; importer.animationPositionError = importerSource.animationPositionError; importer.animationRotationError = importerSource.animationRotationError; importer.animationScaleError = importerSource.animationScaleError; importer.animationType = importerSource.animationType; importer.animationWrapMode = importerSource.animationWrapMode; importer.bakeIK = importerSource.bakeIK; importer.clipAnimations = importerSource.clipAnimations; // importer.defaultClipAnimations = importerSource.defaultClipAnimations; importer.extraExposedTransformPaths = importerSource.extraExposedTransformPaths; // importer.fileScale = importerSource.fileScale; importer.generateAnimations = importerSource.generateAnimations; importer.generateSecondaryUV = importerSource.generateSecondaryUV; importer.globalScale = importerSource.globalScale; importer.humanDescription = importerSource.humanDescription; importer.importAnimation = importerSource.importAnimation; importer.importBlendShapes = importerSource.importBlendShapes; // importer.importedTakeInfos = importerSource.importedTakeInfos; importer.importMaterials = importerSource.importMaterials; // importer.isBakeIKSupported = importerSource.isBakeIKSupported; // importer.isFileScaleUsed = importerSource.isFileScaleUsed; importer.isReadable = importerSource.isReadable; // importer.isTangentImportSupported = importerSource.isTangentImportSupported; // importer.isUseFileUnitsSupported = importerSource.isUseFileUnitsSupported; importer.materialName = importerSource.materialName; importer.materialSearch = importerSource.materialSearch; importer.meshCompression = importerSource.meshCompression; importer.motionNodeName = importerSource.motionNodeName; importer.normalImportMode = importerSource.normalImportMode; importer.normalSmoothingAngle = importerSource.normalSmoothingAngle; importer.optimizeGameObjects = importerSource.optimizeGameObjects; importer.optimizeMesh = importerSource.optimizeMesh; // importer.referencedClips = importerSource.referencedClips; importer.secondaryUVAngleDistortion = importerSource.secondaryUVAngleDistortion; importer.secondaryUVAreaDistortion = importerSource.secondaryUVAreaDistortion; importer.secondaryUVHardAngle = importerSource.secondaryUVHardAngle; importer.secondaryUVPackMargin = importerSource.secondaryUVPackMargin; importer.sourceAvatar = importerSource.sourceAvatar; importer.splitTangentsAcrossSeams = importerSource.splitTangentsAcrossSeams; importer.swapUVChannels = importerSource.swapUVChannels; importer.tangentImportMode = importerSource.tangentImportMode; // importer.transformPaths = importerSource.transformPaths; importer.useFileUnits = importerSource.useFileUnits; }
void ModifyModel () { importedModel = ModelImporter.GetAtPath(_assetPath) as ModelImporter; importedModel.globalScale = 1f; importedModel.importMaterials = false; AssetDatabase.ImportAsset(_assetPath); }