BlockText
How do I use Block Text
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
97 |
Material blockTextMaterial = gameObject.transform.Find ("BlockText").gameObject.GetComponent |
1 |
File name: BlockScript.cs
Copy
94 public void setBlockNumber(int blockNumber) {
95 this.blockNumber = blockNumber;
96 TextMesh textMesh = this.GetComponentInChildren
97 Material blockTextMaterial = gameObject.transform.Find ("BlockText").gameObject.GetComponent
98 MeshRenderer cube = gameObject.GetComponentInChildren
99 Color cubeColor = cube.GetComponent
100
101 //block doesn't exits
102 if(blockNumber == -2) {
103 cube.GetComponent
104 textMesh.text = "";
105 }
106 //block is empty
107 else if (blockNumber == -1 ) {
108 cube.GetComponent
109 cube.GetComponent
110 textMesh.text = "";
111 }
112 //block has a value
113 else {
114 cube.GetComponent
115 cube.material.color = this.getColor (blockNumber);
116 blockTextMaterial.SetColor ("_Color", new Color(1,1,1));
117 if(blockNumber == 0) blockTextMaterial.SetColor ("_Color", new Color(0.8f,0.8f,1));
118 textMesh.text = blockNumber.ToString();
119 transform.position = this.originalPosition;
120 }
121
122 }
BlockText 154 lượt xem
Gõ tìm kiếm nhanh...