Unity引擎内图片高级选项批量修改

</pre><pre name="code" class="csharp">
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using System.Collections.Generic;

/// <summary>
/// 功能:引擎内图片高级选项批量修改
/// 平台:Unity4.6.4/C#
/// 设计模式:命令模式(15) 
/// FileName:TextureManager
/// Creator: Thewen
/// CreateTime:2016/4/20 15:26:45
/// Description:
/// History:
/// </summary>

///<summary>
///命令基类 为子类提供处理具体逻辑的逻辑类
///</summary>
public abstract class Command
{
    protected Receiver _receiver;
    public Command(Receiver receiver)
    {
        this._receiver = receiver;
    }
    public abstract void ExecuteAction();

}
/// <summary>
/// 命令模式关键类 (处理逻辑主体)
/// </summary>
public class Receiver
{
    TextureImporterSettings _importsettings=new TextureImporterSettings();
    bool _iscompress;
    string _texturetype;
    string _path;
    TextureImporterFormat _iosformat;
    TextureImporterFormat _androidformat;

    //默认
    public Receiver(string texturetype, string path)
    {
        this._texturetype = texturetype;
        this._path = path;
        this._importsettings.npotScale = TextureImporterNPOTScale.ToNearest;
        this._importsettings.ApplyTextureType(TextureImporterType.Advanced, false);
        this._importsettings.readable = false;
        this._importsettings.mipmapEnabled = true;
        this._importsettings.lightmap = false;
        this._iscompress = true;
    }
    public Receiver(string texturetype, string path,bool iscompress,bool mipmapenabled ,bool lightmap)
    {
        this._texturetype = texturetype;
        this._path = path;
        this._importsettings.npotScale = TextureImporterNPOTScale.ToNearest;
        this._importsettings.ApplyTextureType(TextureImporterType.Advanced, false);
        this._importsettings.readable = false;
        this._importsettings.mipmapEnabled = mipmapenabled;
        this._importsettings.lightmap = lightmap;
        this._iscompress = iscompress;
    }
    /// <summary>
    /// 设置图片的高级属性
    /// </summary>
    public void SetTextureAnvanceSetting( )
    {
        ArrayList filePath =  TextureManager.GetAssetPath(_texturetype, _path);
        for (int i = 0; i < filePath.Count; i++)
        {
            TextureManager.SetAdvanceForPath(filePath[i].ToString(),_iscompress,_importsettings,_iosformat,_androidformat);
        }
    }
}
/// <summary>
/// 命令执行类 (便于命令的集中管理,为实现撤销于恢复提供可能)
/// </summary>
public class Invoker
{
    public Command _command;
    public List<Command> _commandlist;

    public Invoker(Command command)
    {
        this._command = command;
    }
    public Invoker(List<Command> commandlist)
    {
        this._commandlist = commandlist;
    }
    public void ExecuteCommandList()
    {
        for (int i = 0; i < _commandlist.Count; i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值