In the game development, often because the gameobject,setactive way to open the close, this way the effect is too stiff and give it a tween
It could be alphatween or scaletween.
Plus a playtween to do the control.
This needs to be added to each gameobject on each of these component not to say, it is not very useful
So it's a very, very convenient way to combine a previously used extension function.
(Previous expansion function article: http://blog.csdn.net/chrisfxs/article/details/51221892)
using Unityengine; Using System.Collections; namespace Extensionmethods {public static class MyExtensions {public static void Setactivewithalphat Ween (this gameobject gameobject,bool active) {uitweencontrol<tweenalpha> tween = new UITWEENCONTROL<TW Eenalpha> (); Uiwidget widget = gameobject.getcompoent<uiwidget> (); if (widget = = null) Widget = gameobject.addcompoent<uiwidget> (); if (active) {gameobject.setactive (true); Widget.alpha = 0; Tween. Begin (gameobject,widget.alpha,1,0.3f,0); } else {widget.alpha = 1; Tween. Begin (gameobject,widget.alpha,0,0.3f,0); Tween. Setfinishcallback (Delegate () {tween. Removeeventdelegate (); Gameobjec.setactive (FALSE); }, True); } } } }
One of the above Uitweencontrol is the control of their own encapsulated Uitween class, this you can also package A, you can also use the Ngui, specifically need to modify their own, but the idea is the above, there will be nothing too difficult place.
is to determine if there are tween and widgets when Gameobject is turned on or off, and not added, and use the tween controller to control the gradient switch
This is only used to precede the class with a namespace
Using Extensionmethods;
Then your gameobject can be used directly!
GameObject go; go.SetActiveWithAlphaTween(true);
Wit like Me
"Komatsu teaches you to tour the development" "Unity practical Skills" to each gameobject open close plus a gradient