Search Issue Tracker
By Design
Votes
0
Found in
2019.3
2019.3.0b12
2020.1
Issue ID
1200688
Regression
No
NullReferenceException is thrown when setting ParticleSystemJobData size through IParticleSystemJob
How to reproduce:
1. Open attached project "TestUnity.zip" and scene "ParticleSystemJob_setSize"
2. Enter Play mode
3. Observe Console window
Expected result: no errors are thrown, particle size is set to Vector2.one
Actual result: "NullReferenceException: Object reference not set to an instance of an object" is thrown
Reproducible with: 2019.3.0f1, 2020.1.0a15
Could not test with: 2017.4, 2018.4, 2019.2 (IJobParticleSystem interface is not detected, errors are thrown)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Crash on [NSApplication endModalSession:] when saving while Play Mode is loading
- Incorrect Preferred Height calculation when a single text line uses different Font Assets
- [ShaderGraph] Redo Collapse Nodes action does not fully collapse the Nodes
- [Ubuntu] Mouse cursor is set box select mode after exiting VFX Graph's Rename Context function
- Unrecognized identifier DECLARE_STACK_CB error is thrown when VirtualTexture Property is used with Custom RenderTexture target
Resolution Note:
With the supplied particle system, the size is uniform, therefore we only store a single value per-particle (it would be a waste of memory to store the y and z values).
Therefore, your script should only set the sizes.x property.
To set a different value for each axis of the particle system (non-uniform) enable the 3D Start Size checkbox in the main particle system settings.
public void Execute(ParticleSystemJobData jobData)
{
var sizes = jobData.sizes.x;
for (int i = 0; i < jobData.count; i++)
{
sizes[i] = 1.0f;
}
}