using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System.Collections.Generic; using System; public class ColorPickerPnl: MonoBehaviour, IPointerDownHandler, IDragHandler { public Slider hueSlider; public Slider alphaSlider; // Alpha slider to control transparency public Image saturationValueImage; public InputField hexInput; public Image colorPreview; public RectTransform saturationValueRect; // RectTransform for the Saturation/Value box public GameObject PresetContainer; public Button ButtonTemplate; public GameObject Extension; private Texture2D saturationValueTexture; private Color currentColor = Color.white; void OnEnable() { print("Color enable"); // Initialize saturation/value texture with 200x200 resolution saturationValueTexture = new Texture2D(350, 20); saturationValueImage.sprite = Sprite.Create(saturationValueTexture, new Rect(0, 0, 350, 20), new Vector2(0.5f, 0.5f)); hueSlider.onValueChanged.AddListener(OnHueChanged); alphaSlider.onValueChanged.AddListener(OnAlphaChanged); // Add listener for the alpha slider hexInput.onEndEdit.AddListener(OnHexInputChanged); // Generate the initial saturation/value image based on the hue OnHueChanged(hueSlider.value); // Assign preset color buttons if(PresetContainer.transform.childCount==0){ List HexColor=GetListColor(); for(int i=0; i().color=presetColor; Btn.onClick.AddListener(() => SetPresetColor(presetColor,Btn.name)); } } else{ foreach(Transform BtnTransfom in PresetContainer.transform){ Button Btn = BtnTransfom.GetComponent