private void ChangeSelectedColorKey(int value)
 {
     if (colorKeyObjects.Count() > selectedColorKey)
     {
         colorKeyObjects[selectedColorKey].transform.GetChild(0).GetChild(0).GetComponent <Image>().color = Color.gray;
     }
     if (alphaKeyObjects.Count() > 0)
     {
         alphaKeyObjects[selectedAlphaKey].transform.GetChild(0).GetChild(0).GetComponent <Image>().color = Color.gray;
     }
     colorKeyObjects[value].transform.GetChild(0).GetChild(0).GetComponent <Image>().color = Color.green;
     if (selectedColorKey != value && !ColorPicker.done)
     {
         ColorPicker.Done();
     }
     selectedColorKey = value;
     colorKeyObjects[value].Select();
 }
 /// <summary>
 /// Manually close the GradientPicker and apply the selected color
 /// </summary>
 public static void Done()
 {
     if (!ColorPicker.done)
     {
         ColorPicker.Done();
     }
     foreach (Slider s in instance.colorKeyObjects)
     {
         Destroy(s.gameObject);
     }
     foreach (Slider s in instance.alphaKeyObjects)
     {
         Destroy(s.gameObject);
     }
     instance.colorKeyObjects = null;
     instance.colorKeys       = null;
     instance.alphaKeyObjects = null;
     instance.alphaKeys       = null;
     done = true;
     onGC?.Invoke(modifiedGradient);
     onGS?.Invoke(modifiedGradient);
     instance.transform.parent.gameObject.SetActive(false);
 }
 //checks if Key can be deleted
 public void CheckDeleteKey(Slider s)
 {
     if (Input.GetMouseButtonDown(1))
     {
         if (s.name == "ColorKey" && colorKeys.Count > 2)
         {
             if (!ColorPicker.done)
             {
                 ColorPicker.Done();
                 return;
             }
             int index = colorKeyObjects.IndexOf(s);
             Destroy(colorKeyObjects[index].gameObject);
             colorKeyObjects.RemoveAt(index);
             colorKeys.RemoveAt(index);
             if (index <= selectedColorKey)
             {
                 ChangeSelectedColorKey(selectedColorKey - 1);
             }
             modifiedGradient.SetKeys(colorKeys.ToArray(), alphaKeys.ToArray());
             CalculateTexture();
         }
         if (s.name == "AlphaKey" && alphaKeys.Count > 2)
         {
             int index = alphaKeyObjects.IndexOf(s);
             Destroy(alphaKeyObjects[index].gameObject);
             alphaKeyObjects.RemoveAt(index);
             alphaKeys.RemoveAt(index);
             if (index <= selectedAlphaKey)
             {
                 ChangeSelectedAlphaKey(selectedAlphaKey - 1);
             }
             modifiedGradient.SetKeys(colorKeys.ToArray(), alphaKeys.ToArray());
             CalculateTexture();
         }
     }
 }