Ejemplo n.º 1
0
    public void ChangeSelectedTextureFormatSettings(Object[] textures, TextureImporterData targetImpoterData)
    {
        if (textures == null)
        {
            return;
        }

        Selection.objects = new Object[0];
        foreach (Texture2D texture in textures)
        {
            if (!ChangeTextureFormatSettings(texture, targetImpoterData))
            {
                continue;
            }
        }
    }
Ejemplo n.º 2
0
    protected bool ChangeTextureFormatSettings(Texture2D texture, TextureImporterData targetImpoterData, bool isUsingUnityDeaultCompress = true)
    {
        if (!texture)
        {
            return(false);
        }

        try
        {
            string          path            = AssetDatabase.GetAssetPath(texture);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;

            //if(isUsingUnityDeaultCompress)
            //{
            //	if (targetImpoterData.PlatformOverrideContences != null)
            //	{
            //		foreach (var item in targetImpoterData.PlatformOverrideContences)
            //		{
            //			UnOverridePlatformTextureSetting(textureImporter, item.Key);
            //		}
            //	}
            //	textureImporter.SaveAndReimport();
            //}
            //return true;
            textureImporter.isReadable          = targetImpoterData.Readable;
            textureImporter.sRGBTexture         = targetImpoterData.sRGBTexture;
            textureImporter.mipmapEnabled       = targetImpoterData.MipmapEnabled;
            textureImporter.alphaIsTransparency = targetImpoterData.aTranparency;

            if (targetImpoterData.PlatformOverrideContences != null)
            {
                foreach (var item in targetImpoterData.PlatformOverrideContences)
                {
                    PlatformTextureSetting(textureImporter, item.Key, item.Value, isUsingUnityDeaultCompress);
                }
            }

            textureImporter.SaveAndReimport();
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.Message);
            return(false);
        }
        return(true);
    }
Ejemplo n.º 3
0
    public void Initialize()
    {
        if (TargetImporterData == null)
        {
            TargetImporterData = new TextureImporterData();
        }
        if (QuickSetResolutions == null)
        {
            QuickSetResolutions = new List <string>();
        }
        else
        {
            QuickSetResolutions.Clear();
        }

        QuickSetResolutions.Add("UIAtlas");
        QuickSetResolutions.Add("Charactor");
        QuickSetResolutions.Add("OtherModel");
        CurrentSelectedQuickSetResolution = "UIAtlas";
        OnQuickButtonChanged();
    }