AssetDatabase.WriteImportSettingsIfDirty()

作者:追风剑情 发布于:2018-4-12 11:28 分类:Unity3d

示例

    [MenuItem ("Tool/Write ImportSettings")]
    static void WriteImportSettings()
    {
        //加载资源
        TextureImporter ti = TextureImporter.GetAtPath("Assets/test1/tex.jpg") as TextureImporter;
        Debug.Log(string.Format("maxTextureSize={0}, isReadable={1}", ti.maxTextureSize, ti.isReadable));

        TextureImporterSettings tis = new TextureImporterSettings();
        ti.ReadTextureSettings(tis);//把ti中的值赋给tis
        //修改部分设置
        tis.maxTextureSize = 32;
        tis.readable = true;
        ti.SetTextureSettings(tis);//把tis的值赋给ti
        Debug.Log(string.Format("maxTextureSize={0}, isReadable={1}", ti.maxTextureSize, ti.isReadable));

        //保存设置到disk
        AssetDatabase.WriteImportSettingsIfDirty(ti.assetPath);
        //更新资源
        AssetDatabase.ImportAsset(ti.assetPath, ImportAssetOptions.ForceUpdate);
    }

测试

111.jpg

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号