public static void OnPostprocessSpriteAtlas(string assetPath) { var spriteAtlas = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(assetPath); if (!CustomAssetPostprocessor.IsNewCreateFile(assetPath)) { return; } var postprocessorUtils = SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); var guid = postprocessorUtils.Get(PostprocessorAssetType.SpriteAtlas, assetPath); if (string.IsNullOrEmpty(guid)) { return; } var path = AssetDatabase.GUIDToAssetPath(guid); var so = AssetDatabase.LoadAssetAtPath <SoSpriteAtlasPostprocessor>(path); if (so == null) { so = SoAssetPostprocessor.GetDefault(PostprocessorAssetType.SpriteAtlas) as SoSpriteAtlasPostprocessor; } SetIncludeInBuild(spriteAtlas); SetPackingSettings(spriteAtlas); SetTextureSettings(spriteAtlas); SetPlatformSettings(spriteAtlas, so); EditorUtility.SetDirty(spriteAtlas); AssetDatabase.SaveAssets(); }
private AssetPostprocessorFolderTab(EditorWindow parent, TreeViewState state) : base(state) { this.parent = parent; showAlternatingRowBackgrounds = true; soAssetPostprocessorUtils = SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); searchField = new SearchField(); }
private void Refresh() { SoAssetPostprocessorUtils.VerifyConfigs(); folderTab?.Refresh(); configTab?.Refresh(); assetListTab?.Refresh(); }
private AssetListTab(TreeViewState state) : base(state) { showAlternatingRowBackgrounds = true; postprocessorUtils = SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); warnIcon = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Editor/AssetPostprocessor/Texture/Warn.png"); errorIcon = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Editor/AssetPostprocessor/Texture/Error.png"); searchField = new SearchField(); stateContents = new GUIContent[] { new GUIContent("None"), new GUIContent("Normal"), new GUIContent("Warn", warnIcon), new GUIContent("Error", errorIcon), }; verticalSplitPercent = 0.7f; }
static bool CompareMaterialSetting(ModelImporter importer, SoModelPostprocessor so, ref string message) { var same = true; var sameInfo = string.Empty; if (importer.importMaterials != so.ImportMaterials) { same = false; sameInfo = StringUtil.Contact(sameInfo, "\n", "ImportMaterials"); } if (importer.materialLocation != so.MaterialLocation) { same = false; sameInfo = StringUtil.Contact(sameInfo, "\n", "MaterialLocation"); } if (importer.importMaterials && importer.materialLocation == ModelImporterMaterialLocation.InPrefab) { var objects = AssetDatabase.LoadAllAssetsAtPath(importer.assetPath); if (objects != null && objects.Length > 0) { for (int i = 0; i < objects.Length; i++) { if (objects[i] is Material) { var mat = objects[i] as Material; postprocessorUtils = postprocessorUtils ? postprocessorUtils : SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); if (postprocessorUtils.ContainsStandardShader(mat.shader.name)) { same = false; sameInfo = StringUtil.Contact(sameInfo, "\n", "Using Standard Shader"); break; } } } } } if (!same) { message = StringUtil.Contact(message, "\n", "<b>Material</b>", sameInfo); } return(same); }
private void OnDeleteSoAssetPostprocessor(string deleteGuid) { var so = SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); var defaultSo = SoAssetPostprocessor.GetDefault(selectAssetType); var defaultGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(defaultSo)); var paths = so.GetPaths(selectAssetType); for (int i = 0; i < paths.Count; i++) { var path = paths[i]; var guid = so.Get(selectAssetType, path); if (guid == deleteGuid) { so.Set(selectAssetType, path, defaultGuid); } } }
public static void OnPreprocessTexture(TextureImporter importer) { var assetType = (PostprocessorAssetType)(-1); if (importer.assetPath.Contains("Sprite")) { assetType = PostprocessorAssetType.Sprite; } else if (importer.assetPath.Contains("Texture")) { assetType = PostprocessorAssetType.Texture; } if (assetType != PostprocessorAssetType.Sprite && assetType != PostprocessorAssetType.Texture) { return; } var postprocessorUtils = SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); var guid = postprocessorUtils.Get(assetType, importer.assetPath); if (string.IsNullOrEmpty(guid)) { return; } var path = AssetDatabase.GUIDToAssetPath(guid); SoTexturePostprocessorBase soPostprocessor = null; if (!string.IsNullOrEmpty(path)) { soPostprocessor = AssetDatabase.LoadAssetAtPath <SoTexturePostprocessorBase>(path); } if (soPostprocessor == null) { soPostprocessor = SoAssetPostprocessor.GetDefault(assetType) as SoTexturePostprocessorBase; } importer.textureType = assetType == PostprocessorAssetType.Sprite ? TextureImporterType.Sprite : TextureImporterType.Default; SetDefaultSettings(assetType, importer); SetPlatformSettings(importer, soPostprocessor); }
public static void OnPostprocessModel(ModelImporter importer) { postprocessorUtils = postprocessorUtils ? postprocessorUtils : SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); var guid = postprocessorUtils.Get(PostprocessorAssetType.Model, importer.assetPath); if (string.IsNullOrEmpty(guid)) { return; } var path = AssetDatabase.GUIDToAssetPath(guid); var so = AssetDatabase.LoadAssetAtPath <SoModelPostprocessor>(path); if (so == null) { so = SoAssetPostprocessor.GetDefault(PostprocessorAssetType.Model) as SoModelPostprocessor; } SetSettings(importer, so); Reimport(importer, so); }
private AssetPostprocessorConfigTab(TreeViewState state) : base(state) { soAssetPostprocessorUtils = SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils(); showAlternatingRowBackgrounds = true; rowHeight = 25; }