Size: a a a

Unity Floodилка

2020 December 30

DS

David Sedrakyan in Unity Floodилка
источник

DS

David Sedrakyan in Unity Floodилка
что вы думаете на счет этого ?
источник

DS

David Sedrakyan in Unity Floodилка
Actually it's best to use InvokeRepeating where possible. I did a test on 5000 objects, where each one runs this:

Code (csharp):
private var i = 0;

function Start () {
   InvokeRepeating("Test", .01, 1.0);
}

function Test () {
   i++;
}
That normally takes .03 milliseconds per frame, with spikes of 2.38 ms every second (when all 5000 functions run).

Using this code instead:

Code (csharp):
function Start () {
   var i = 0;
   while (true) {
       i++;
     
       yield WaitForSeconds(1.0);
   }
}
also takes .03 ms per frame, but the spikes are 4.03 ms every second. Using Update:

Code (csharp):
private var timer = 0.0;
private var i = 0;

function Update () {
   if (Time.time >= timer) {
       timer = Time.time + 1.0;
       i++;
   }
}
takes an average of .93 ms per frame (no noticeable spikes every second, since the overhead overwhelms whatever CPU time the actual code uses, even multiplied by 5000). At about 100fps, that's a total of 93 ms per second, whereas the coroutine is a total of 7.03 ms per second and InvokeRepeating is 5.38 ms per second.
источник

DS

David Sedrakyan in Unity Floodилка
вот сам его текст
источник

P

Phantom in Unity Floodилка
David Sedrakyan
Actually it's best to use InvokeRepeating where possible. I did a test on 5000 objects, where each one runs this:

Code (csharp):
private var i = 0;

function Start () {
   InvokeRepeating("Test", .01, 1.0);
}

function Test () {
   i++;
}
That normally takes .03 milliseconds per frame, with spikes of 2.38 ms every second (when all 5000 functions run).

Using this code instead:

Code (csharp):
function Start () {
   var i = 0;
   while (true) {
       i++;
     
       yield WaitForSeconds(1.0);
   }
}
also takes .03 ms per frame, but the spikes are 4.03 ms every second. Using Update:

Code (csharp):
private var timer = 0.0;
private var i = 0;

function Update () {
   if (Time.time >= timer) {
       timer = Time.time + 1.0;
       i++;
   }
}
takes an average of .93 ms per frame (no noticeable spikes every second, since the overhead overwhelms whatever CPU time the actual code uses, even multiplied by 5000). At about 100fps, that's a total of 93 ms per second, whereas the coroutine is a total of 7.03 ms per second and InvokeRepeating is 5.38 ms per second.
Code (csharp):

function Start () {
источник

DS

David Sedrakyan in Unity Floodилка
Phantom
Code (csharp):

function Start () {
чо?
источник

P

Phantom in Unity Floodилка
function
источник

DS

David Sedrakyan in Unity Floodилка
private/public missing ?
источник

P

Phantom in Unity Floodилка
David Sedrakyan
private/public missing ?
function
источник

DS

David Sedrakyan in Unity Floodилка
чооооо
источник

P

Phantom in Unity Floodилка
David Sedrakyan
чооооо
function
источник

DS

David Sedrakyan in Unity Floodилка
че хочешь
источник

DS

David Sedrakyan in Unity Floodилка
?
источник

G

Graf in Unity Floodилка
function
источник

DS

David Sedrakyan in Unity Floodилка
понял
источник

DS

David Sedrakyan in Unity Floodилка
function
источник

P

Phantom in Unity Floodилка
David Sedrakyan
че хочешь
Найди мне в шарпе function
источник

DS

David Sedrakyan in Unity Floodилка
Phantom
Найди мне в шарпе function
ну это ж псевдо код
источник

DS

David Sedrakyan in Unity Floodилка
ну или unityscript
источник

DS

David Sedrakyan in Unity Floodилка
когда то был
источник