2011. 7. 2. 01:24
아래 코드는 Texture 들을 선택해서 일괄적으로 포멧을 변경하는 코드입니다.
응용하면 다른 타입도 가능합니다.
아래 코드는 Assets/Editor/CusomMenu.cs 에 생성하셔야 합니다.
응용하면 다른 타입도 가능합니다.
아래 코드는 Assets/Editor/CusomMenu.cs 에 생성하셔야 합니다.
using UnityEditor;
using UnityEngine;
using System.Collections;
public class CustomMenu : ScriptableObject
{
// ----------------------------------------------------------------------------
[MenuItem ("CustomMenu/Texture Format")]
static void ChangeTexture()
{
SeletedChangeTexture();
}
static void SeletedChangeTexture()
{
Object[] textures = GetSelectedTextures();
Selection.objects = new Object[0];
int count = 0;
foreach(Texture2D texture in textures)
{
count++;
string path = AssetDatabase.GetAssetPath(texture);
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
//texture.wrapMode = TextureWrapMode.Clamp;
textureImporter.textureType = TextureImporterType.Advanced;
textureImporter.mipmapEnabled = false;
textureImporter.npotScale = TextureImporterNPOTScale.None;
textureImporter.maxTextureSize = 4096;
textureImporter.textureFormat = TextureImporterFormat.AutomaticTruecolor;
AssetDatabase.ImportAsset(path);
Debug.Log(string.Format("[{0}/{1}] ChangeTexture progress : {2}", count, textures.Length, path));
}
}
static Object[] GetSelectedTextures()
{
return Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets);
}
}
'Dev > Unity3D' 카테고리의 다른 글
| unity3d data path! (0) | 2011.12.14 |
|---|---|
| Unity3D Mesh Create Code (0) | 2011.10.20 |
| Unity3D 에서 XML Serialize Encrypt/Decrypt. (3) | 2011.04.22 |
| FindObjectOfType fail. (0) | 2010.12.14 |
| Unity Script 와 Obejct-C 연동. (0) | 2010.11.09 |


