Base class from which asset importers for specific asset types derive.
/// <inherit/> public override void Apply(AssetImporter assetImporter) { ModelImporter importer = (ModelImporter)assetImporter; importer.globalScale = scaleFactor; importer.meshCompression = meshCompression; importer.isReadable = readWriteEnabled; importer.optimizeMesh = optimizeMesh; importer.importBlendShapes = importBlendShapes; importer.addCollider = generateColliders; importer.swapUVChannels = swapUVs; importer.generateSecondaryUV = generateLightmapUV; importer.normalImportMode = normals; importer.tangentImportMode = tangents; importer.normalSmoothingAngle = smoothingAngle; importer.importMaterials = importMaterials; if (importer.importMaterials) { importer.materialName = materialNaming; importer.materialSearch = materialSearch; } }
/// <summary> /// 查询需打包的字体文件 /// </summary> public static void SearchFileNeedBuild(string buildPath, List <string> suffix) { string[] filePaths = Directory.GetFiles(buildPath); for (int i = 0; i < filePaths.Length; i++) { if (filePaths[i] == buildPath) { continue; } string _filePath = filePaths[i].ToLower(); foreach (string suf in suffix) { if (_filePath.Contains(suf)) { if (!_filePath.Contains("meta")) { string fileName = Path.GetFileName(_filePath); int idx = _filePath.IndexOf("assets/"); string impPath = _filePath.Substring(idx); UnityEditor.AssetImporter assetImporter = UnityEditor.AssetImporter.GetAtPath(impPath); assetImporter.assetBundleName = fileName; assetImporter.assetBundleVariant = TCommon.ABSUFFIX; } } } } }
/// <summary> /// 更新bundle名 /// </summary> private void QuickUpdate() { StateObjectHolder obj = target as StateObjectHolder; for (int i = 0; i < obj.bundleList.Count; i++) { foreach (var item in obj.bundleList[i].itemList) { var path = AssetDatabase.GUIDToAssetPath(item.guid); var prefab = AssetDatabase.LoadAssetAtPath <GameObject>(path); if (prefab == null) { UnityEditor.EditorUtility.DisplayDialog("空对象", item.ID + "预制体为空", "确认"); continue; } string assetPath = UnityEditor.AssetDatabase.GetAssetPath(prefab); UnityEditor.AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(assetPath); item.assetName = prefab.name; if (string.IsNullOrEmpty(item.assetName)) { UnityEditor.EditorUtility.DisplayDialog("提示", "预制体" + item.assetName + "没有assetBundle标记", "确认"); return; } else { item.assetBundleName = importer.assetBundleName; } } } EditorUtility.SetDirty(target); }
private void UpdateOnLocalBundleInfo(SerializedProperty itemProp) { var guidProp = itemProp.FindPropertyRelative("guid"); var goodProp = itemProp.FindPropertyRelative("good"); var assetNameProp = itemProp.FindPropertyRelative("panelName"); var bundleNameProp = itemProp.FindPropertyRelative("bundleName"); if (!goodProp.boolValue) { UnityEditor.EditorUtility.DisplayDialog("空对象", assetNameProp.stringValue + "信息错误", "确认"); } else { string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(guidProp.stringValue); var obj = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath); UnityEditor.AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(assetPath); assetNameProp.stringValue = obj.name; bundleNameProp.stringValue = importer.assetBundleName; //if (string.IsNullOrEmpty(bundleNameProp.stringValue)) //{ // UnityEditor.EditorUtility.DisplayDialog("提示", "预制体" + assetNameProp.stringValue + "没有assetBundle标记", "确认"); //} } }
public override void ApplySettings(UnityEditor.AssetImporter assetImporter) { AudioImporter importer = assetImporter as AudioImporter; if (importer == null) { return; } importer.forceToMono = forceToMono; if (forceToMono) { //importer.normalize = normalize; } importer.loadInBackground = loadInBackground; importer.ambisonic = ambisonic; importer.preloadAudioData = preloadAudioData; AudioImporterSampleSettings sampleSettings = importer.defaultSampleSettings; sampleSettings.loadType = loadType; sampleSettings.compressionFormat = compressionFormat; sampleSettings.quality = quality; sampleSettings.sampleRateSetting = sampleRateSetting; sampleSettings.sampleRateOverride = (uint)sampleRate; importer.defaultSampleSettings = sampleSettings; importer.SetOverrideSampleSettings("Android", sampleSettings); importer.SetOverrideSampleSettings("iPhone", sampleSettings); //importer.SaveAndReimport(); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { for (int i = 0; i < movedAssets.Length; i++) { UnityEditor.AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(movedAssets[i]); //model: if (importer is ModelImporter) { ExcuteMeshRule(importer); } //texture: else if (importer is TextureImporter) { ExcuteTextureRule(importer); } //audio else if (importer is AudioImporter) { ExcuteAudioRule(importer); } } }
void QuickLoadObject() { string name = prefab.name; string assetPath = UnityEditor.AssetDatabase.GetAssetPath(prefab);// UnityEditor.AssetDatabase.GetTextMetaFilePathFromAssetPath(.asset(prefab)[0]; UnityEditor.AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(assetPath); string assetBundle = importer.assetBundleName; if (string.IsNullOrEmpty(assetBundle)) { UnityEditor.EditorUtility.DisplayDialog("提示", "预制体没有assetBundle标记", "确认"); return; } if (bundles.Find((x) => x.assetName == name) != null) { UnityEditor.EditorUtility.DisplayDialog("提示", "信息已经加载到集合中", "确认"); return; } RunTimeBundleInfo info = new RunTimeBundleInfo(); info.assetName = name; info.bundleName = assetBundle; info.isWorld = !prefab.GetComponent <RectTransform>(); info.parent = transform; bundles.Add(info); UnityEditor.EditorUtility.SetDirty(this); }
public override void ApplySettings(UnityEditor.AssetImporter assetImporter) { TextureImporter importer = assetImporter as TextureImporter; if (importer == null) { return; } dirty = true; importer.textureType = textureType; importer.textureShape = textureShape; //importer.allowAlphaSplitting = allowsAlphaSplitting; importer.npotScale = npotScale; importer.isReadable = isReadable; importer.mipmapEnabled = mipmapEnabled; importer.wrapMode = wrapMode; importer.filterMode = filterMode; importer.anisoLevel = anisoLevel; importer.maxTextureSize = maxTextureSize; importer.textureCompression = textureCompression; SetAndroidTextureImporterSettings(importer, AndroidTextureImporterSettings.format); SetiPhoneTextureImporterSettings(importer, iOSTextureImporterSettings.format); }
/// <inherit/> public override void Apply(AssetImporter assetImporter) { TextureImporter importer = (TextureImporter)assetImporter; importer.textureType = TextureImporterType.Advanced; importer.npotScale = nonPowerOf2; if (nonPowerOf2 != TextureImporterNPOTScale.None) { importer.generateCubemap = generateCubemap; } importer.isReadable = readWriteEnabled; importer.grayscaleToAlpha = alphaFromGreyscale; importer.generateMipsInLinearSpace = bypassSampling; importer.spriteImportMode = spriteMode; importer.spritePackingTag = packingTag; importer.spritePixelsToUnits = pixelsToUnits; importer.mipmapEnabled = generateMipMaps; importer.wrapMode = wrapMode; importer.filterMode = filterMode; importer.anisoLevel = anisoLevel; importer.textureFormat = format; }
private void QuickUpdateBundles() { for (int i = 0; i < bundlesProp.arraySize; i++) { var itemProp = bundlesProp.GetArrayElementAtIndex(i); var guidProp = itemProp.FindPropertyRelative("guid"); var goodProp = itemProp.FindPropertyRelative("good"); var assetNameProp = itemProp.FindPropertyRelative("assetName"); var bundleNameProp = itemProp.FindPropertyRelative("bundleName"); if (!goodProp.boolValue) { UnityEditor.EditorUtility.DisplayDialog("空对象", assetNameProp.stringValue + "信息错误", "确认"); continue; } string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(guidProp.stringValue); var obj = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath); UnityEditor.AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(assetPath); assetNameProp.stringValue = obj.name; bundleNameProp.stringValue = importer.assetBundleName; if (string.IsNullOrEmpty(bundleNameProp.stringValue)) { UnityEditor.EditorUtility.DisplayDialog("提示", "预制体" + assetNameProp.stringValue + "没有assetBundle标记", "确认"); return; } } UnityEditor.EditorUtility.SetDirty(this); }
public static void Rewrite(ref Texture2DArray texArr, Texture2DArray newArr) { #if UNITY_EDITOR bool isSelected = UnityEditor.Selection.activeGameObject == texArr; UnityEditor.AssetImporter texImporter = texArr.GetImporter(); if (texImporter == null) { return; } //string userData = texImporter.userData; //do not owerwrite userdata UnityEditor.EditorUtility.CopySerialized(newArr, texArr); UnityEditor.EditorUtility.SetDirty(texArr); UnityEditor.AssetDatabase.SaveAssets(); if (isSelected) { UnityEditor.Selection.activeObject = texArr; } //texArr = UnityEditor.AssetDatabase.LoadAssetAtPath<Texture2DArray>(path); //texArr.GetImporter().userData = userData; #endif }
public override bool ApplySettings(UnityEditor.AssetImporter importer) { m_CurImpoter = importer as TextureImporter; m_CurImpoter.textureType = m_textureType; return(true); }
public bool IsMatch(UnityEditor.AssetImporter importer) { if (importer is TextureImporter) { return(true); } return(false); }
public override bool IsMatch(UnityEditor.AssetImporter importer) { if (importer is ModelImporter) { return(true); } return(false); }
//カスタムインポート対象のMovieか bool IsCustomImportMovie(AssetImporter importer) { AdvScenarioDataProject project = AdvScenarioDataBuilderWindow.ProjectData; if (project) { return project.IsCustomImportMovie(importer); } return false; }
//カスタムインポート対象のテクスチャか AdvScenarioDataProject.TextureType ParseCustomImportTextureType(AssetImporter importer) { AdvScenarioDataProject project = AdvScenarioDataBuilderWindow.ProjectData; if (project) { return project.ParseCustomImportTextureType(importer); } return AdvScenarioDataProject.TextureType.Unknown; }
public override void ApplySettings(UnityEditor.AssetImporter assetImporter) { ModelImporter importer = assetImporter as ModelImporter; if (importer != null) { ApplyMeshSettings((ModelImporter)assetImporter); } }
public override void ApplySettings(UnityEditor.AssetImporter assetImporter) { TextureImporter importer = assetImporter as TextureImporter; if (importer != null) { ApplyAssetSettings((TextureImporter)assetImporter); } }
/// <inherit/> public override void Apply(AssetImporter assetImporter) { AudioImporter importer = (AudioImporter)assetImporter; importer.format = audioFormat; importer.threeD = _3DSound; importer.forceToMono = forceMono; importer.loadType = loadType; importer.hardware = hardwareDecoding; importer.loopable = gaplessLooping; importer.compressionBitrate = compression; }
private static void ExcuteTextureRule(UnityEditor.AssetImporter importer) { TextureAssetRule rule = FindRuleForAsset <TextureAssetRule>(importer.assetPath, "t:TextureAssetRule"); if (rule == null) { Debug.Log("No texture rules found for asset"); } else { rule.ApplySettings(importer); } }
public override bool ApplySettings(UnityEditor.AssetImporter importer) { if (base.ApplySettings(importer) == false) { return(false); } m_CurImpoter = importer as TextureImporter; m_CurImpoter.textureType = m_textureType; return(true); }
private static void ExcuteAudioRule(UnityEditor.AssetImporter importer) { AudioAssetRule rule = FindRuleForAsset <AudioAssetRule>(importer.assetPath, "t:AudioAssetRule"); if (rule == null) { Debug.Log("No audio rules found for asset"); } else { rule.ApplySettings(importer); } }
private static void ExcuteMeshRule(UnityEditor.AssetImporter importer) { ModelAssetRule rule = FindRuleForAsset <ModelAssetRule>(importer.assetPath, "t:ModelAssetRule"); if (rule == null) { Debug.Log("No model rules found for asset"); } else { rule.ApplySettings(importer); } }
public override bool ApplySettings(UnityEditor.AssetImporter importer) { m_CurImpoter = importer as ModelImporter; if (m_CurImpoter == null) { return(false); } ApplyRig(); ApplyAnimations(); ApplyModel(); return(true); }
public bool IsEqual(AssetImporter importer) { if(importer.GetType() != referenceImporter.GetType()) { throw new AssetBundleGraphException("Importer type does not match."); } if(importer.GetType() == typeof(UnityEditor.TextureImporter)) { return IsEqual(importer as UnityEditor.TextureImporter); } else if(importer.GetType() == typeof(UnityEditor.AudioImporter)) { return IsEqual(importer as UnityEditor.AudioImporter); } else if(importer.GetType() == typeof(UnityEditor.ModelImporter)) { return IsEqual(importer as UnityEditor.ModelImporter); } else { throw new AssetBundleGraphException("Unknown importer type found:" + importer.GetType()); } }
public override void ApplySettings(UnityEditor.AssetImporter assetImporter) { AudioImporter importer = assetImporter as AudioImporter; if (importer == null) { return; } importer.loadInBackground = LoadBackground; AudioImporterSampleSettings sampleSetting = importer.defaultSampleSettings; sampleSetting.loadType = LoadType; sampleSetting.compressionFormat = CompressionFormat; sampleSetting.sampleRateSetting = SampleRate; // importer.GetOverrideSampleSettings("Android"); // importer.SaveAndReimport(); }
private static ImportSettings FindImportSettings(AssetImporter assetImporter) { int[] dashIndices = assetImporter.assetPath.IndexesWhere(c => c == '/').ToArray(); for (int i = dashIndices.Length - 1; i > 0; i--) { string path = assetImporter.assetPath.Substring(0, dashIndices[i]); IEnumerable<string> guids = FolderInspector.GetSettingGUIDs(path); if (guids == null) { continue; } foreach (string guid in guids) { ImportSettings importSettings = Utility.LoadObjectFromGUID<ImportSettings>(guid); if (importSettings != null && importSettings.IsValid(assetImporter)) { return importSettings; } } } return null; }
public override void ApplySettings(UnityEditor.AssetImporter assetImporter) { ModelImporter importer = assetImporter as ModelImporter; if (importer == null) { return; } importer.globalScale = scaleFactor; importer.meshCompression = meshCompression; importer.isReadable = isReadable; importer.optimizeMesh = optimizeMeshForGPU; importer.importBlendShapes = importBlendShapes; importer.addCollider = generateColliders; importer.keepQuads = keepQuads; importer.weldVertices = weldVertices; importer.swapUVChannels = swapUVChannels; importer.generateSecondaryUV = generateSecondaryUV; //Normals & Tangents importer.importNormals = normalImportMode; importer.normalSmoothingAngle = normalSmoothAngle; importer.importTangents = tangentImportMode; importer.importMaterials = importMaterials; importer.materialName = materialName; //rig importer.animationType = animationType; importer.optimizeGameObjects = isOptimizeObject; //animations importer.importAnimation = importAnimation; importer.animationCompression = animCompression; Debug.Log("Modifying Model Import Settings, An Import will now occur and the settings will be checked to be OK again during that import"); //importer.SaveAndReimport(); }
public ImportSettingsConfigurator(AssetImporter referenceImporter) { this.referenceImporter = referenceImporter; }
/// <summary> /// 宴用のカスタムインポート設定を強制するMovieアセットかチェック /// </summary> public bool IsCustomImportMovie(AssetImporter importer) { string assetPath = importer.assetPath; foreach (Object folderAsset in CustomInportMovieFolders) { if (assetPath.StartsWith(AssetDatabase.GetAssetPath(folderAsset))) { return true; } } return false; }
public InternalSamplingImportEffector(AssetImporter importerSourceObj) { this.importerSourceObj = importerSourceObj; }
static void MenuRemoveAB() { AssetDatabase.RemoveUnusedAssetBundleNames(); List <string> fileList = new List <string>(); List <string> fileRemove = new List <string>(); /// 遍历 目录 操作 if (null != Selection.objects) { for (int index = 0; index < Selection.objects.Length; index++) { if (null != Selection.objects[index]) { string path = string.Format("{0}/../{1}", Application.dataPath, AssetDatabase.GetAssetPath(Selection.objects[index])); if (System.IO.Directory.Exists(path)) { EditorSearchFile.SearchPath(path, fileList, ""); } else { fileList.Add(path); } } } } /// 资源剔除处理 RemoveSameAndUnExportAssets(fileList, fileRemove); /// 打印 LOG for (int index = 0; index < fileList.Count; index++) { UnityEditor.AssetImporter importer = UnityEditor.AssetImporter.GetAtPath("Assets" + fileList[index].Substring(fileList[index].IndexOf("/Resources-/"))); if (null == importer) { continue; } /// 为空返回 if (string.IsNullOrEmpty(importer.assetBundleName) && string.IsNullOrEmpty(importer.assetBundleVariant)) { continue; } /// 设置 Debug.Log(string.Format("Remove AssetBundle : {0}.{1}", importer.assetBundleName, importer.assetBundleVariant)); importer.SetAssetBundleNameAndVariant("", ""); importer.SaveAndReimport(); } for (int index = 0; index < fileRemove.Count; index++) { UnityEditor.AssetImporter importer = UnityEditor.AssetImporter.GetAtPath("Assets" + fileRemove[index].Substring(fileRemove[index].IndexOf("/Resources-/"))); if (null == importer) { continue; } /// 没设置 返回 if (string.IsNullOrEmpty(importer.assetBundleName) && string.IsNullOrEmpty(importer.assetBundleVariant)) { continue; } /// 的是依赖 返回 if (importer.assetBundleName.StartsWith("d/")) { continue; } /// 设置 Debug.LogError(string.Format("Remove AssetBundle : {0}.{1}", importer.assetBundleName, importer.assetBundleVariant)); importer.SetAssetBundleNameAndVariant("", ""); importer.SaveAndReimport(); } }
/// <summary> /// 宴用のカスタムインポート設定を強制するSpriteアセットかチェック /// </summary> public TextureType ParseCustomImportTextureType(AssetImporter importer) { string assetPath = importer.assetPath; foreach (Object folderAsset in CustomInportSpriteFolders) { string floderPath = AssetDatabase.GetAssetPath(folderAsset); if (assetPath.StartsWith(floderPath)) { string name = System.IO.Path.GetFileName( floderPath ); TextureType type; if (UtageToolKit.TryParaseEnum<TextureType>(name, out type)) { return type; } return TextureType.Unknown; } } return TextureType.Unknown; }
public virtual bool IsMatch(UnityEditor.AssetImporter importer) { return(false); }
public void OverwriteImportSettings(AssetImporter importer) { if(importer.GetType() != referenceImporter.GetType()) { throw new AssetBundleGraphException("Importer type does not match."); } if(importer.GetType() == typeof(UnityEditor.TextureImporter)) { OverwriteImportSettings(importer as UnityEditor.TextureImporter); } else if(importer.GetType() == typeof(UnityEditor.AudioImporter)) { OverwriteImportSettings(importer as UnityEditor.AudioImporter); } else if(importer.GetType() == typeof(UnityEditor.ModelImporter)) { OverwriteImportSettings(importer as UnityEditor.ModelImporter); } else { throw new AssetBundleGraphException("Unknown importer type found:" + importer.GetType()); } }
public static void Attach (AssetImporter newImporter) { importerSourceObj = newImporter; }
private SubstanceImporter GetImporter() { return(AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(this.target)) as SubstanceImporter); }
/** * Attempt to read user data attached to a mesh by qe_Editor. */ public static bool GetMeshUserData(AssetImporter assimp, out string originalImportedMeshPath, out string originalImportedMeshSubAssetName) { string[] data = assimp.userData.Split('?'); if(data.Length == 2) { originalImportedMeshPath = data[0]; originalImportedMeshSubAssetName = data[1]; return true; } originalImportedMeshPath = ""; originalImportedMeshSubAssetName = ""; return false; }
public static extern Texture2D GetWaveForm(AudioClip clip, AssetImporter importer, int channel, float width, float height);
public static void Detach () { importerSourceObj = null; }
public static Texture2D GetWaveForm(AudioClip clip, AssetImporter importer, int channel, float width, float height) { return (Texture2D)GetWaveForm__MethodInfo.Invoke(null,new object[]{clip,importer,channel,width,height}); }
/// <summary> /// Apply settings to the asset importer. /// </summary> /// <param name="assetImporter">Asset importer for current object being updated.</param> public abstract void Apply(AssetImporter assetImporter);
public virtual void ApplySettings(UnityEditor.AssetImporter importer) { }
/// <summary> /// Are these settings applicable to this asset importer? /// </summary> /// <param name="assetImporter">Asset importer for current object being updated.</param> /// <returns>True, if these import settings should be used.</returns> public virtual bool IsValid(AssetImporter assetImporter) { return AssetType == assetImporter.GetType(); }