Skip to content

Instantly share code, notes, and snippets.

@nicloay
Created September 7, 2015 11:39
Show Gist options
  • Select an option

  • Save nicloay/b34ea9a4b8675247cf51 to your computer and use it in GitHub Desktop.

Select an option

Save nicloay/b34ea9a4b8675247cf51 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.UI;
public class DisableToggleBG : MonoBehaviour {
Image cr;
void Awake () {
cr = GetComponent<Image>();
GetComponentInParent<Toggle>().onValueChanged.AddListener((state) => {OnParentToggleChange(state);});
}
void OnParentToggleChange(bool state){
cr.enabled = !state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment