Last active
February 4, 2016 03:14
-
-
Save kimsama/109f481552375a9f20c1 to your computer and use it in GitHub Desktop.
Various NGUI and its EventTrigger usage on script side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // with tweening animation... | |
| TweenAlpha transition = TweenAlpha.Begin(FadeOut.gameObject, this.fadeInTime, duration); | |
| transition.from = 0f; | |
| transition.ResetToBeginning(); | |
| EventDelegate.Add(transition.onFinished, OnFinished, true); | |
| void OnFinished() | |
| { | |
| // called at the end of alpha tweening animation. | |
| } | |
| // A simple dragging. | |
| // add or retrieve UIEventTrigger | |
| UIEventTrigger eventTrigger = gameObject.GetComponent<UIEventTrigger>(); | |
| eventTrigger.onDragEnd.Add(new EventDelegate(OnDragEnd)); | |
| ... | |
| void OnDragEnd() | |
| { | |
| // get delta distances with the dragging. | |
| float delta = UICamera.currentTouch.totalDelta.x; | |
| // ignore the dragging less than 10 | |
| if (Mathf.Abs(delta) < 10f) | |
| return; | |
| // do something | |
| // ... | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment