void OnPreprocessTexture() { CustomTextureImportScriptableObject[] importers = GetAllTargetScriptableObject(); if (importers == null || importers.Length < 1) { return; } CustomTextureImportScriptableObject targetImporter = null; for (int i = 0; i < importers.Length; i++) { var item = importers[i]; // 対象のPathチェック if (!assetPath.Contains(item.Path)) { continue; } // 拡張子指定チェック bool isTargetExtention = false; if (item.ExtentionList != null && item.ExtentionList.Length > 0) { for (int j = 0; j < item.ExtentionList.Length; j++) { isTargetExtention |= assetPath.Contains(item.ExtentionList[j]); } } else { //指定なし isTargetExtention = true; } if (!isTargetExtention) { continue; } targetImporter = item; break; } if (targetImporter == null) { return; } var importer = assetImporter as TextureImporter; importer.textureType = targetImporter.ImporterSettings.TextureType; importer.alphaIsTransparency = targetImporter.ImporterSettings.AlphaIsTransparency; importer.alphaSource = targetImporter.ImporterSettings.AlphaSource; importer.mipmapEnabled = targetImporter.ImporterSettings.MipmapEnabled; importer.wrapMode = targetImporter.ImporterSettings.WrapMode; }
public static void CreateTargetObject() { CustomTextureImportScriptableObject targetObject = CreateInstance <CustomTextureImportScriptableObject> (); if (!System.IO.Directory.Exists(DEFAULT_SCRIPTABLEOBJECT_GENERATED_PATH)) { System.IO.Directory.CreateDirectory(DEFAULT_SCRIPTABLEOBJECT_GENERATED_PATH); } string path = AssetDatabase.GenerateUniqueAssetPath(DEFAULT_SCRIPTABLEOBJECT_GENERATED_PATH + DEFAULT_SCRIPTABLEOBJECT_FILENAME); AssetDatabase.CreateAsset(targetObject, path); AssetDatabase.Refresh(); }