Class PuddlecraftRain
- Namespace
- DFA.Puddlecraft
Draws the falling rain around a camera. Every drop is drawn by the GPU in a single call, so even a downpour of a hundred thousand drops costs the CPU almost nothing.
The drops take their look from the particle system on this object, which never emits particles itself: its material, Start Size (a single value or a range), Start Colour (one or two), and its renderer's Speed Scale, Length Scale and Min Particle Size. Its Max Particles caps the number of drops. The splashes and mist are ordinary particle systems and can be edited freely. How the rain falls (how much, how fast and how far around the camera) is set on the Rain Preset, under Rainfall.
The Rain Preset names this prefab, and Puddlecraft spawns it: around the camera in Play mode, and around the Scene view camera in Edit mode when Preview in Scene View is on. The copies are never saved in the scene. Each copy is drawn only for the camera it falls around, so the Scene view never shows the game camera's rain, and vice versa.
Drops belong to the world, not to the camera. Each one lands exactly on the surface below it, as found in the rain cover map, so drops stop on roofs and awnings instead of falling through them. Moving the camera, quickly, in any direction or by teleporting, reveals drops that were already on their way down. Where a drop lands, the Splashes system emits a splash and the water there gets rings. Drops are visible from Spawn Height above the camera downwards, and reach at least Fallback Depth below it.
[AddComponentMenu("Puddlecraft/Rain Particles")]
[DisallowMultipleComponent]
[ExecuteAlways]
[RequireComponent(typeof(ParticleSystem))]
[Icon("Packages/com.dfa.puddlecraft/editor/icons/puddlecraft.png")]
public sealed class PuddlecraftRain : MonoBehaviour
- Inheritance
-
PuddlecraftRain
Properties
followCamera
Camera the rain falls around in Play mode, and the only camera that draws it. Null: the main camera.
public Camera followCamera { get; set; }
Property Value
mist
The particle system for low mist over the ground in heavy rain, or null.
public ParticleSystem mist { get; set; }
Property Value
splashes
The particle system that gets one particle where each raindrop or drip-edge drip lands within the preset's splashRadius, or null.
public ParticleSystem splashes { get; set; }