Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: DevMan5000 on October 05, 2014, 03:44:01 PM

Title: Inheriting from UIProgressBar, getting value changed event
Post by: DevMan5000 on October 05, 2014, 03:44:01 PM
Hello,

My class PaganationDotBar inherits from UIProgressBar and is assigned to be the horizontal scrollbar on a scroll view.

UIProgressBar has a property "value".

Without modifying the NGUI class UIProgressBar, is there a way for my inherited class to be notified when that value changes?

I tried the following:
  1. public override float value
  2.         {
  3.                 get
  4.                 {
  5.                         return base.value;
  6.                 }
  7.                 set
  8.                 {
  9.                         base.value = value;
  10.                         Debug.Log("Got there!");
  11.                 }
  12.         }

However, I cannot override the property because it is not marked as virtual. The other option would be to add a callback to the onChange event delegate array, but that seems strange because that seems like it would be used to notify outside objects, not one which inherits from UIProgressBar.

What would you do here?

Thanks!
Title: Re: Inheriting from UIProgressBar, getting value changed event
Post by: ArenMook on October 06, 2014, 10:03:17 AM
There is the onChange notification.
  1. EventDelegate.Set(slider.onChange, YourFunctionToCall);