Unity Hand 2048 mini-game-background text control

Source: Internet
Author: User

Go ahead with yesterday's plan today.

1, the new project, the scene name what do not say it.

2, directly start a new image, by the way, renamed image to Chessman

3. Select the image to create a new text object and adjust the size position. So it's done in a grid.

4. Start the code, create a new code named Chessman, and put the code under Chessman. The code is as follows:

usingUnityengine;usingSystem.Collections;usingUnityengine.ui; Public classChessman:monobehaviour {PrivateImage imageobj; PrivateText textobj; voidStart () {imageobj= getcomponent<image> (); Imageobj.raycasttarget=false; Textobj= getcomponentinchildren<text> (); Textobj.raycasttarget=false; }    //Change background Image Color     Public voidFN_CHANGEBG (Color _colorvalue) {Imageobj.color=_colorvalue; }    //change the text, and the corresponding color     Public voidFn_changetext (string_textvalue,color _colorvalue) {Textobj.text=_textvalue; Textobj.color=_colorvalue; }}

Start () has: Imageobj.raycasttarget = false;

Textobj.raycasttarget = false;

This is to not accept the radiation, save resources. This is what the elder told me, so that can save resources (suddenly feel unsure, so to speak, it seems to be a good excuse to shake the pot).

Note that when the value is 0, the A channel must be set to transparent regardless of the RGB values (00)

Unity Hand 2048 mini-game-background text control

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.