Created
March 3, 2014 04:32
-
-
Save s2kw/9318408 to your computer and use it in GitHub Desktop.
画像のImport時の設定を自動化する例。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class ImportSettingFormatter{ | |
[MenuItem("Tools/TextureFormat")] | |
public static void Format() | |
{ | |
Object[] images = Resources.LoadAll("image",typeof(Texture2D)); | |
foreach(var obj in images) | |
{ | |
string path = AssetDatabase.GetAssetPath(obj); | |
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; | |
textureImporter.textureType = TextureImporterType.GUI; | |
textureImporter.maxTextureSize = 256;//ここは適当に適切なサイズを返す関数で対応すべし。 | |
AssetDatabase.ImportAsset(path); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
最初の行の…
は、Resources/image/ 以下にある全てのTexture2Dとして読み取る事の出来るアセットを対象にしてるので、"image" -> "image/icon/bullet"にするなり適せん変更を。
TextureTypeはGUI以外にすると正方形に変身してしまいます。
maxTextureSizeは、pathからどのディレクトリに格納されているかを正規表現などで条件分けしてint(ただし、2のべき乗)を返す関数などで対応しておりましたよ。