Skip to content

Instantly share code, notes, and snippets.

@jeedee
Created May 30, 2011 19:11
Show Gist options
  • Save jeedee/999338 to your computer and use it in GitHub Desktop.
Save jeedee/999338 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
// The below references should be populated
// by dragging the desired controls from
// scene hierarchy onto these variables in
// the inspector:
// Reference to a slider
public UISlider slider;
// Reference to a radio button
public UIRadioBtn radioBtn;
void Start()
{
// Register our delegate with both controls:
slider.SetValueChangedDelegate(MyDelegate);
radioBtn.SetValueChangedDelegate(MyDelegate);
}
// The delegate itself
void MyDelegate(IUIObject obj)
{
if(obj == slider)
Debug.Log("The slider's value is: " + slider.Value);
else if(obj == radioBtn)
Debug.Log("The radio button's value is: " + radioBtn.Value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment