Author Topic: Inheriting from UIProgressBar, getting value changed event  (Read 2762 times)

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Inheriting from UIProgressBar, getting value changed event
« 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!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Inheriting from UIProgressBar, getting value changed event
« Reply #1 on: October 06, 2014, 10:03:17 AM »
There is the onChange notification.
  1. EventDelegate.Set(slider.onChange, YourFunctionToCall);