Hi, I'd like to create a (2D) particle system where the particles would be a number or a word. I'd like the option to change the text via code as I spawn a new particle system, but I am trying to avoid manually creating a bunch of diffuse bitmaps with just numbers and words, as doing it via Text and code seems like more optimized option..?
I guess I am looking for a way to convert a UI Text or similar into a Material, or use the Text as an Opacity map for the material, which I can apply to the particle system.
Is it possible, any suggestions?
Answer by LiloE
Mar 02 at 06:58 PM
Thanks to your question, I've created my first Unity tutorial video.
And the subject is: Particles with Dynamic Text :-)
The idea is to use another camera and a canvas
The second camera renders its own overlay canvas onto a render texture.**
This texture will then be assigned to a material that will be used by the particle system.
Since the material keeps changing when you change the text, the particles are also changed.
(This is for advanced users, if you get stuck, watch the video tutorial below)
Create a new 2d scene (works also on 3d scene but that's how I did this)
Create a particle system and set it in front of the camera
Change particle settings so that particles will be slower and bigger:I set Start Speed to 1 and Min Particle Size to 0.1Tweak these values to your liking
Min Particle Size
Create another camera, let's call it Text Camera
Set it to be orthographic and move it a bit so it will be out of the way
Create a new Render Texture, call it Text Renderer
In the Text Camera set the target texture to be the Text Renderer
Disable the audio listener on Text Camera, as you can't have two of them in a scene.
Create a canvas, set it to Screen Space - Camera and select the text-camera as its camera
Screen Space - Camera
In the canvas create a panel, set its color to black and full opacity (by default it's half!)
Add a text object to the panel, let's leave it with the default name Text, set its color to white and resize it to fit nicely inside the panel
Check that in the Text Camera you can see the text clearly and that it more or less fills the frame
Create a new material, call it Text Material and set its shader to one of the particle shaders, I used "Mobile/Particles/Additive"
Set the texture of the Text Material to be Text Renderer
You should now see in the material preview the current text that you entered in the Text object
Go to the particle system and set the material in the renderer to Text Material
which explains everything step by step
Answer by Tronotrond
Mar 05 at 02:17 AM
Awesome! Thank you so much! Your instructions worked like a charm, and is exactly what I was wanting! :D
Please don't add comments as answers, that's what the "Add comment" buttons are for.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
113 People are following this question.
Instantiated Particle System not random
Are there any disadvantages to using the legacy Ellipsoid Particle System in Unity 5 over Shuriken.
How to make a particle system evenly lit?
Little dust particles after player jump hitting ground
I have a particle system that is playing at the wrong time...