Question by
tomkevmuhsha · Oct 18, 2016 at 02:39 PM ·
unity 2dtutorialscount
Code to replace the "count" commands in C# for text.
I am making a an app similar to this. In the 8th video, a scoring feature is added. Is there anyway to edit that code so instead of counting every time an object is picked up, that text is displayed instead. An example of the code to COUNT:
if (other.gameObject.CompareTag("PickUp"))
{
other.gameObject.SetActive(false);
count = count + 1;
countText.text = "Count: " + count.ToString();
}
}
void SetCountText()
{
countText.text = "Count: " + count.ToString ();
}
Comment
If you just make a UI canvas and place a Text object there and assign it to countText, this should work.
Your answer
![](https://koobas.hobune.stream/wayback/20220612094907im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can i decrease lives? 0 Answers
Allocating 2 GB of memory for strings on scene load? 0 Answers
Screen Size 0 Answers
Unity 2D rotation not smooth? 0 Answers