- Home /
Hi. Can I use sprites by the particle system for reduce draw calls?
My issue: In my game I draw background objects by SpriteRenderer, then I use the particle system for snowflakes, and then i use SpriteRenderer for the game object. The backgrounds and the game objects use sprites from one texture and one material(Sprites-Default). I have 3 draw calls: 1 - background, 2 - particles, 3 - game objects. I wanted reduce draw calls, but I have no idea how I can do that. I wrote a script that copy materialPropertyBlock from SpriteRenderer and set It to ParticleSystem renderer:
Renderer renderer = GetComponent<Renderer>();
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
renderer.sharedMaterial = spriteRenderer.sharedMaterial;
spriteRenderer.GetPropertyBlock(propertyBlock);
renderer.SetPropertyBlock(propertyBlock);
(this works and Stats shows 1 drawcall, but sometimes, when I open the project, Unity gives the error to the console: ptr == NULL || GET_CURRENT_ALLOC_ROOT_REFERENCE() == NULL || GET_CURRENT_ALLOC_ROOT_REFERENCE() == GET_ROOT_REFERENCE(s_MonoDomainContainer, kMemMono) UnityEngine.MaterialPropertyBlock:.ctor() ) It bothers me. And I would like to know how to reduce draw calls in this situation?
P.S. I wanted write a script for generating meshes to don't use Unity sprite system, but maybe Can I get around that?
You have only 3 drawcalls, but you want to reduce it further? Do you have any reason to believe that doing so will have a noticeable impact?
In this situation I have 3 calls, but what happened when I'll use this order: sprites-particles-sprites-particles-sprites-particles I'll get 6 calls with one material and one texture. :-)
Your answer
Follow this Question
Related Questions
Mesh particle effects are not showing up in WebGL build 2 Answers
Create entity by particles 0 Answers