using System; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(UITexture))] [RequireComponent(typeof(UIButton))] public class ColorPresetItem : MonoBehaviour { public int slotNo { get { return this.slotNo_; } set { if (this.slotNo_ != value) { this.slotNo_ = value; this.UpdateData(); } } } private void Start() { this.UpdateData(); } private void Awake() { if (this.uiTex == null) { this.uiTex = base.GetComponent(); } this.grayTexArray = UTY.GetPixelArray(this.greyTex); this.colorChangeTex = new Texture2D(this.greyTex.width, this.greyTex.height, TextureFormat.RGBA32, false, true); EventDelegate.Add(base.GetComponent().onClick, new EventDelegate.Callback(this.OnButtonClick)); } public void UpdateData() { Dictionary editColorPresetData = GameMain.Instance.CMSystem.GetEditColorPresetData(this.slotNo); if (editColorPresetData == null) { this.uiTex.mainTexture = this.emptyTex; } else { ColorPaletteManager.ColorData colorData = ColorPaletteManager.ColorData.RestoreData(MaidParts.PARTS_COLOR.EYE_L, editColorPresetData); UTY.ConvertColor(new MaidParts.PartsColor { m_nMainHue = colorData.main.hue, m_nMainChroma = colorData.main.chroma, m_nMainBrightness = colorData.main.brightness, m_nMainContrast = colorData.main.contrast, m_nShadowHue = colorData.shadow.hue, m_nShadowChroma = colorData.shadow.chroma, m_nShadowBrightness = colorData.shadow.brightness, m_nShadowContrast = colorData.shadow.contrast, m_nShadowRate = colorData.shadowRate }, this.grayTexArray, ref this.colorChangeTex); this.uiTex.mainTexture = this.colorChangeTex; } this.uiTex.SetDimensions(this.uiTex.mainTexture.width, this.uiTex.mainTexture.height); } private void OnButtonClick() { int num = -1; int num2 = -2; if (UICamera.currentTouchID == num2) { GameMain.Instance.CMSystem.RemoveEditColorPresetData(this.slotNo); this.UpdateData(); } else if (UICamera.currentTouchID == num) { if (this.uiTex.mainTexture == this.emptyTex) { if (this.onSaveColorPresetEvent != null) { Dictionary storeData = this.onSaveColorPresetEvent().GetStoreData(); GameMain.Instance.CMSystem.SetEditColorPresetData(this.slotNo, storeData); this.UpdateData(); } } else if (this.onLoadColorPresetEvent != null) { this.onLoadColorPresetEvent(GameMain.Instance.CMSystem.GetEditColorPresetData(this.slotNo)); } } } [SerializeField] private Texture2D emptyTex; [SerializeField] private Texture2D greyTex; public Func onSaveColorPresetEvent; public Action> onLoadColorPresetEvent; private Texture2D colorChangeTex; private UITexture uiTex; private int slotNo_; private byte[] grayTexArray; }