转换效果
HSV范围
HSV 为色相,饱和度,明度。HSV色域如下
在Unity中HSV的范围如下:
H: 0 — 360
S: 0 — 255
V: 0 — 255
源码
//---------------------------
//主要功能:批量修改图片中的颜色(例如从黄色替换为绿色)
//---------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;
public class TextureChangeColor : MonoBehaviour
{
private const string m_FilePath = @"Assets\Resources\Png\";//文件夹
//private const string m_TexturePath = @"Assets\Resources\Png\002.png";//具体图片
private string m_CurrentTexturePath = null;//具体图片
private const int HSV_H = 360;
private const int HSV_S = 255;
private const int HSV_V = 255;
//HSV黄色范围
private const float HSV_Yellow_H_Max = 68f;
private const float HSV_Yellow_H_Min = 26f;
private const float HSV_Yellow_S_Max = 255f;
private const float HSV_Yellow_S_Min = 43f;//43是按照最大值100来的
private const float HSV_Yellow_V_Max = 255f;
private const float HSV_Yellow_V_Min = 43f;
//HSV绿色范围
private const float HSV_Green_H_Max = 154f;
private const float HSV_Green_H_Min = 35f