# Count up timer for unity3d in minutes,seconds and milliseconds c#

I have been asked about how to make a count up timer in unity so many times, that i finally decided to share a simple script that does that, so here it goes.

this script will also format the timer to “00:00:00”

create a C# script in unity and add the following code to it:

float minutes = 0f;
float seconds = 0f;
float milliseconds = 0f;
string minutesS =””;
string secondsS = “”;
string millisecondsS = “”;

void Update(){

if(milliseconds >= 100){
if(seconds >= 59){
minutes++;
seconds = 0;
}
else if(seconds < 59){
seconds++;
}
milliseconds= 0;
}
milliseconds+= Time.deltaTime * 100;
if (minutes < 10) {
minutesS = “0” + minutes;
}
else {
minutesS = “” + minutes;
}

if (seconds < 10) {
secondsS = “0” + seconds;
}
else {
secondsS = “” + seconds;
}

if ((int)milliseconds < 10) {
millisecondsS = “0” + (int)milliseconds;
}
else {
millisecondsS = “” + (int)milliseconds;
}

Debug.Log(string.Format(“{0}:{1}:{2}”, minutesS, secondsS, millisecondsS));
}

# Quad or Objects grid creation for unity 3D tutorial C#

Difficulty Beginner

Objectives:

• Create a grid of quad objects in unity 3D
• modify the grid’s columns and rows count
• modify the separation between each grid unit in two axis
• modify the script to be able to use prefabs instead of just quads

Tutorial:

Lets Start Off by creating a C# script: right click in the project window and choose Create->C# Script just like in the image Below now lets rename the script: GridScript

Double click the script to open it in monodevelop or your assigned IDE we get something like the script below. now lets start by creating our variables:

Above void Start write the following: