简单暴力一点啊,不多废话直接上步骤
1. class内建三个float分别代表HSV(Hue,Saturatoin,Value), 同时用三个slider控制value
2. Canvas内拉个白图,通过喜好的方式reference和HSV reference一下
3. 通过Color.HSVToRGB(float H,float S,float V)函数创建新的Color,和想要改变颜色的Color互相更新一下就ok了
UMA部分拉到最底下
代码部分:共有两个class (我知道public reference不是好习惯……我会克服懒惰的)
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ColorPicker : MonoBehaviour { public Color colorPicked; public float H = 0; public float S = 0; public float V = 0; public Image colorShower; private void Start() { colorPicked = Color.HSVToRGB(H, S, V); } public float HSVChangeHolder(int index,float value) { if (index == 0) ChangeH(value); else if (index == 1) ChangeS(value); else if (index == 2) ChangeV(value); return index; } void UpdateColor() { colorPicked = Color.HSVToRGB(H, S, V); colorShower.color = colorPicked; } public void ChangeH(float value) { H = value * 1; UpdateColor(); } public void ChangeS(float value) { S = value * 1; UpdateColor(); } public void ChangeV(float value) { V = value * 1; UpdateColor(); } }
含蓄的分割
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ColorPickerSlider : MonoBehaviour { public Slider slider; public ColorPicker colorPicker; public int HSVIndex; private void Start() { slider.onValueChanged.AddListener(delegate { DelegateChange(); }); } void DelegateChange() { colorPicker.HSVChangeHolder(HSVIndex, slider.value); } }
含蓄的二分割
void UpdateColor() { colorPicked = Color.HSVToRGB(H, S, V); colorShower.color = colorPicked; UMA.SlotData slot = human.GetComponent<UMA.UMAData>().GetSlot(slotIndex); List<UMA.OverlayData> list = slot.GetOverlayList(); foreach (var v in list) { v.SetColor(0, colorPicked); v.SetAdditive(0, colorPicked); } //The below is super important!!!Wont work without setting dirty!!! human.GetComponent<UMA.UMAData>().isTextureDirty = true; human.GetComponent<UMA.UMAData>().Dirty(); }
暂无关于此日志的评论。