Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: sangramdange on April 14, 2014, 02:13:31 PM

Title: how to Play sound automatically when item is centered in scroll view
Post by: sangramdange on April 14, 2014, 02:13:31 PM
hi all
i am pretty new to NGUI.
i could play sound on mouse press, mouse release and so on but how to Play sound automatically when item is centered in scroll view
regards
sangram
Title: Re: how to Play sound automatically when item is centered in scroll view
Post by: ArenMook on April 15, 2014, 09:18:27 AM
UICenterOnChild has the onFinished delegate you can set. Set it to your custom function that will play a sound inside.
Title: Re: how to Play sound automatically when item is centered in scroll view
Post by: sangramdange on April 15, 2014, 03:01:42 PM
thanks Michael
but since am a newbie  can you just give me hint on how to access the onfinished delegate in UICentreOnChild script,  through a custom script.
I was checking the uibutton message script that makes it very simple to understand. its has public variables  like Target, function name, trigger.. all i do is make a gameobject attach a custom script to it and put that in the target and access the function name that is set in my custom script....Simple and works great
bu cant do the  same with UICentreOnChild script.
Title: Re: how to Play sound automatically when item is centered in scroll view
Post by: ArenMook on April 16, 2014, 10:18:49 AM
  1. EventDelegate.Add(centerOnChild.onFinished, MyFunction);
Same as it is with tweens, pretty much. Here's the full code of how to do it with a tween, for reference:
  1. void OnClick()
  2. {
  3.     TweenPosition tp = TweenPostion.Begin(targetObject, duration, targetPos);
  4.     EventDelegate.Add(tp.onFinished, MyFunction);
  5. }
  6.  
  7. public void MyFunction ()
  8. {
  9.     Debug.Log("Tween finished");
  10. }