NGUI grayed out icon button--no increase of drawcall

Source: Internet
Author: User
Tags new set

Some places in the game may need to be grayed out to show that the button cannot be clicked! Found on the Internet some of the methods are directly with uitexture+ gray shader to do this thing, but each plus 1 uitexture will be one more drawcall! In addition some programs are not very clear, can not understand! But also basically is to use the ashing shader, it is impossible to say that every need to gray place the picture let the art out of a map of the corresponding gray resources, so waste space.

  My workaround is this:

0. Need a ashing effect of the shader, specific direct online search to find the relevant shader code on it!

1. Created Atlas Common_atlas (including three files that generated the map Atlas Common_atlas.png, the preset common_atlas.prefab, the material common_atlas.mat).

2. Copy the Atlas preset, the atlas material, name Gray_common_atlas.prefab, Gray_common_atlas.mat, and then gray_common_ the material file Atlas.mat default shader is specified as the grayed-out shader selected earlier, so using this ashing prefab sprite is a ashing effect .

3. In operation, once a button or icon sprite (their atlas is specified as normal common_atlas.prefab) needs to be grayed out, this time dynamically set Sprite.atlas to Gray_common_ Atlas.prefab, when you need to set a normal state, the reverse is set to normal Common_atlas.prefab.

4. Of course, due to the Atlas property of the sprite you are not good to go to the new one, so I am in the layout stage, each with a new set of 1 Sprite, and then select the corresponding Atlas, and then put this sprite in a monomer class Allatlas, Once the sprite of a button or icon needs to dynamically set the specified Atlas property, the corresponding Sprite.atlas in Allatlas is assigned to it.

For example Awardsprite.atlas = AllAtlas.Instance.CommonSprite.atlas, so that you set the desired atlas!

Now this is thought of the best use of the ashing button, there are better or have errors with each other, thank you, reprint please indicate the source!

NGUI grayed out icon button--no increase of drawcall

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.