"Komatsu teaches you to tour the development" "Unity practical Skills" to each gameobject open close plus a gradient

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.