Version: 2023.1

TextureImporter.SetTextureSettings

切换到手册
public void SetTextureSettings (TextureImporterSettings src);

描述

Sets texture importers settings from TextureImporterSettings class.

using UnityEngine;
using UnityEditor;

// Automatically convert any texture with "SingleChannel" // in its path into a single channel texture, and set it to use the red color channel.

class SingleChannelPreprocessor : AssetPostprocessor { void OnPreprocessTexture() { if (assetPath.Contains("SingleChannel")) { TextureImporter textureImporter = (TextureImporter)assetImporter; textureImporter.textureType = TextureImporterType.SingleChannel; TextureImporterSettings settings = new TextureImporterSettings(); textureImporter.ReadTextureSettings(settings); settings.singleChannelComponent = TextureImporterSingleChannelComponent.Red; textureImporter.SetTextureSettings(settings); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961