IEnumerator
At the innerInstantiate
If i do a lot, the Profiler Scripts value will be very large.
Destroy ()
OrInstantiate ()
Is famous for heavy processing, but even if the frame is delayed, this value will gradually increase.
void Start ()
{
Start Coroutine (name of (Generate));
}
IEnumerator Generate ()
{
for (int i = 0;i<1000;i ++)
{
Instantiate (new GameObject, transform.position, Quaternion.identity);
}
}
In the code aboveyield return null;
I just added.
void Start ()
{
Start Coroutine (name of (Generate));
}
IEnumerator Generate ()
{
for (int i = 0;i<1000;i ++)
{
Instantiate (new GameObject, transform.position, Quaternion.identity);
yield return null;
}
}
A few seconds after the start ↓
Dozens of seconds after the start ↓
Process without delaying the frame
The code in will freeze the moment the scene starts, and after a dozen seconds it will thaw and you can play the game comfortably (at least the Profiler Scripts won't grow abnormally).
Process with delayed frame
In the code of, the scene starts immediately after loading the scene, and at first it was at the limit of 30 FPS, but it does not freeze and the player does not have to wait.
However, after a few tens of seconds, the FPS will start to fall below 10.
Instantiate
It is understandable that the value of Scripts will temporarily increase as a result.
And it's understandable without even thinking about freezing when it's required to generate 1000 GameObjects at a time.
However, while giving some room to the CPU (yield return null
I don't understand that the value of Scripts is gradually increasing even though I am creating a game object (by adding).
Not surprisingly, as the number of game objects increases, the rendering process takes longer.
As far as I can see from the profiler above, the cause of the low FPS is Scripts.
Does this happen because the object isn't created in time?
Why is this value increasing little by little without moving in parallel (keeping the same value)?
Please answer somebody.
-
Answer # 1
Related articles
- c # - how to use the button itself generated by instantiate as an argument
- internal processing when calling c # event handler
- c # - how to use unity3d "instantiate" and "setactive"
- c # - prefabs made with unity's instantiate are not displayed
- c # - node deletion during xml loop processing
- c # - [unity] i want to create a function that increases the numerical value by changing the scene
- c # - regarding details of processing to round up datetime in arbitrary units
- c # - [unity] i can't use instantiate well and get an error
- c # - can't give commands to objects created with instantiate
- c # - [unity] coroutine processing and processing in update function are batting
- c # - double quotation processing in process start argument
- i want to speed up tesseract jpn processing (windows10, visual studio 2019, c #, net 47)
- [c #] i want to realize the recursive call processing that can be realized in c ++ also in c #
- i want to implement cancellation processing of c # task
- c # timer settings and processing speed
- c # - i want to gradually expand the screen of the winning player once the victory or defeat is decided
- c # - if (-1 <i:1) i saw this kind of processing in {} for statement do you have a historical background? (beginner)
- c # - processing result of crim's trimend method becomes meaningless
- java - [processing] want to instantiate every second
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
The components contained in the created object were rampaging.
I optimized it and solved it.