D
D
DANICH702021-01-18 12:02:01
Unity
DANICH70, 2021-01-18 12:02:01

How to make a time counter from this code?

There is a code for calculating time from a number (like a timer), how can I make a stopwatch from this code (like a time counter)? Here is the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Timer : MonoBehaviour
{

    public float timeStart = 120;
    public Text timerText;

    // Start is called before the first frame update
    void Start()
    {
        timerText.text = timeStart.ToString();
    }

    // Update is called once per frame
    void Update()
    {
        timeStart -= Time.deltaTime;
        timerText.text = Mathf.Round(timeStart).ToString();
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2021-01-18
@DANICH70

Change minus to plus.

Y
Yaroslav, 2017-05-16
@ivankirshin

Maybe output this:
o.datetime_order >= $date_start
AND o.datetime_order <= $date_end
from under join'a in where?
For example:
SELECT w.name_worker,
w.surname_worker,
w.midname_worker,
w.id_worker,
SUM(number) numb
FROM workers w
LEFT JOIN exhours e ON (w.id_worker = e.id_worker)
LEFT JOIN orders o ON (e .id_order = o.id_order)
where
o.datetime_order >= $date_start
AND o.datetime_order <= $date_end
GROUP BY w.id_worker
Because now it turns out like this:
1. All records of the Workers table will be displayed
2. _all_ records will be attached to them exhours table by id_worker field
3. Records of the orders table will also be attached, _for which the datetime_order field falls into the specified fork_
However, the number field is stored in the exhours table!
Alternatively, one could do this:
SELECT w.name_worker,
w.surname_worker,
w.midname_worker,
w.id_worker,
SUM(h.number) numb
FROM
workers w
left join
(select e.id_worker, e.number from
exhours e inner join orders o on e.id_order = o.id_order
where o.datetime_order >= $date_start
AND o.datetime_order <= $date_end) h
on w.id_worker = h.id_worker
GROUP BY w.id_worker

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question