BlockText









How do I use Block Text
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


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().material;
98   MeshRenderer cube = gameObject.GetComponentInChildren();
99   Color cubeColor = cube.GetComponent().material.color;
100
101   //block doesn't exits
102   if(blockNumber == -2) {
103    cube.GetComponent().enabled = false;
104    textMesh.text = "";
105   }
106   //block is empty
107   else if (blockNumber == -1 ) {
108    cube.GetComponent().enabled = false;
109    cube.GetComponent().material.color = new Color(1, 1, 1, 0.2f);
110    textMesh.text = "";
111   }
112   //block has a value
113   else {
114    cube.GetComponent().enabled = true;
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...