Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 7, 2022 17:17:51 GMT
So basically, initialize time is just a delay, nothing else, my bad.
I tried out Pool Kit (https://assetstore.unity.com/packages/tools/utilities/pool-kit-the-ultimate-pooling-system-for-unity-121174) just for kicks, it has a lazy instantiation which does exactly what i explained, slowly pooling items throughout a pre-set time frame, that's a great feature that would be really cool in CGK.
I don't quite get you on this one?
Use case i have is slow loading time on weaker hardware (no SSD primarily and slow CPU's) and no way to hide the instantiation of so many objects due to dynamic nature of the game (SHMUP). For example, first boss has its own assortment of bullets and needs about 100 of them but there's no spot where i can stuff in the creation of 100 items. But, since you need about 100 seconds to reach him, you can create 1 bullet each second and avoid main thread blocks. I started making the game like 5 years ago when i knew nothing about programming and performance management, you should actually have a pool of bullets and change the animator, collider, speed and other characteristics on runtime so you don't need to pool 100x50 different types of bullets. Unfortunately, i'm to far off to change that now, hence the workarounds that i need.
|
|
|
Post by DarkTonic Dev on Jan 7, 2022 17:32:20 GMT
It's not just a delay. It does stop short of Instantiating all prefab clones on frame one, which is what happens if you keep that at 1 frame. It rations the prefab Instantiation across X frames.
I will put it on the roadmap to investigate partial prefab instantiation per frame, however it will probably be awhile before I get to it.
-B
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 7, 2022 17:38:29 GMT
Well, a delay if you only have one prefab in a pool, but yes, i get it how it works now.
Cool, thanks, both for the good intention and clarifying things up.
|
|
|
Post by DarkTonic Dev on Jan 7, 2022 18:56:40 GMT
Yeah it's of no use if you have one prefab haha.
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 7, 2022 23:50:56 GMT
What would happen if i made a script to call CreateNewPoolItem, set preloadInstances to 1 and then repeat it after desired number of frames until i create as many instances i need?
Would i get "this prefab is already in the pool, not creating"?
I mean, i'm even ready to clone an item 100 times and set init frames to 100 so it creates one instance each frame, but it doesn't let me.
|
|
|
Post by DarkTonic Dev on Jan 8, 2022 0:06:34 GMT
Yes you would. You can only have 1 of each prefab (by name).
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 8, 2022 0:19:35 GMT
Damn.
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 8, 2022 0:24:26 GMT
What about spawning and despawning instances with allow instantiate more allowed, will that expand the pool and leave it expanded?
|
|
|
Post by DarkTonic Dev on Jan 8, 2022 1:03:54 GMT
That would work once the pool item is active (all items declared in the Inspector are instantiated). Or you could just have 1000 of the prefab already in the Scene, and just despawn them (saving on the instantiation).
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 8, 2022 8:40:24 GMT
Great, i guess that will have to do. Thanks.
|
|
|
Post by DarkTonic Dev on Jan 8, 2022 17:14:07 GMT
No prob.
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 15, 2022 8:35:04 GMT
Anyway, i just wanted to let you know that there's no way to use most of the Unity API (instantiate and destroy included) in worker threads since they are not thread safe. It can't be done with Jobs either. Only stuff that can be used are mostly operations with certain data types (background calculations etc.). Only way to speed up instantiations is with ECS but then you're using Entities and you don't actually need pooling anymore. So that's that 
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 15, 2022 8:37:32 GMT
However, i saw your post on Unity forums on addressables, have you done some tests with them? Is there any noticeable difference in i initialization of the pools (creating items) with addressables loaded beforehand?
Or it basically boils down to saving memory by soft referencing on runtime?
|
|
|
Post by DarkTonic Dev on Jan 15, 2022 18:26:11 GMT
I doubt there's a performance increase with Addressables. There could even be a penalty depending on how you pack the bundle.
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 15, 2022 21:28:57 GMT
I doubt there's a performance increase with Addressables. There could even be a penalty depending on how you pack the bundle. Yeah, probably.
|
|