1

我正在尝试制作一个编辑器脚本来设置我的图像的导入设置。我不想做这本手册,因为我需要导入数百张图像。

所以我想设置编辑默认导入设置。

我尝试了以下方法:

using System.Collections;
using System.Collections.Generic;
using UnityEditor;

[InitializeOnLoad]
public class EditorSettings : Editor {

    private static TextureImporter CustomImporter;

    static EditorSettings()
    {
        CustomImporter.npotScale.None; // see below for error.
    }
}

我得到的错误如下:

无法使用实例引用访问成员“TextureImporterNPOTScale.None”;改为使用类型名称来限定它

我该怎么做呢?(这与统一如何让我访问属性有关。)
这甚至是更改图像导入设置的正确方法吗?

让我知道是否有任何不清楚的地方,以便我澄清。

4

1 回答 1

1

我该怎么做呢?这甚至是更改图像导入设置的正确方法吗?

不,这不是如何更改图像的导入设置。要更改导入图像的设置,您必须创建一个派生的编辑器脚本,AssetPostprocessor然后更改函数中的图像设置,该OnPostprocessTexture函数将在图像完成导入时调用。图像随着TextureImporter班级而改变。

public class PostprocessImages : AssetPostprocessor
{
    void OnPostprocessTexture(Texture2D texture)
    {
        TextureImporter textureImporter = (TextureImporter)assetImporter;
        textureImporter.npotScale = TextureImporterNPOTScale.None;
    }
}
于 2018-08-17T16:31:10.867 回答