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