Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Toggles are bugged in 2022.3.13

Discussion in 'Editor & General Support' started by mrCharli3, Nov 30, 2023.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    In 2022.3.13 a toggle with "None" set as transition will still override the image of the toggle, so colors set from other scripts dont get applied. I can see the color changing in the inspector, but it does not change visually in my scene.

    If I disable the toggle my other scripts work fine.

    If I change any setting on the Toggle after starting my scene, my other scripts work fine.

    My script that should handle color transitions instead of Toggle's own version:
    Code (CSharp):
    1. public class ToggleTransitionColor : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
    2. {
    3.     [SerializeField] Toggle toggle;
    4.     [SerializeField] Image image;
    5.     [SerializeField] Color hoverColor;
    6.     [SerializeField] Color selectColor;
    7.  
    8.     Color startColor;
    9.  
    10.     private void Awake()
    11.     {
    12.         startColor = image.color;
    13.     }
    14.  
    15.     public void OnPointerClick(PointerEventData eventData)
    16.     {
    17.         image.color = selectColor;
    18.     }
    19.  
    20.     public void OnPointerEnter(PointerEventData eventData)
    21.     {
    22.         if(toggle.isOn)
    23.         {
    24.             return;
    25.         }
    26.  
    27.         image.color = hoverColor;
    28.     }
    29.  
    30.     public void OnPointerExit(PointerEventData eventData)
    31.     {
    32.         if (toggle.isOn)
    33.         {
    34.             return;
    35.         }
    36.  
    37.         image.color = startColor;
    38.     }
    39. }