Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NullReferenceException - Prefab related?
#1
Hello,

I have a prefab that contains an emitter, emitter shapes, a solver, and 2d sprites. I noticed that particles were rendering from an emitter shape that I had marked inactive. I also unchecked all emitter shapes and the particles still rendered. I then started to remove emitter shapes (which makes prefab no longer a prefab instance). Now when I am in game mode I get the following errors even though I still have a solver, emitter, emitter shapes.

NullReferenceException: Object reference not set to an instance of an object
Obi.ObiEmitter.OnSolverStepBegin () (at Assets/Obi/Scripts/Actors/ObiEmitter.cs:403)
Obi.ObiSolver.SimulateStep (Single stepTime) (at Assets/Obi/Scripts/Solver/ObiSolver.cs:545)
Obi.ObiSolver.FixedUpdate () (at Assets/Obi/Scripts/Solver/ObiSolver.cs:745)

NullReferenceException: Object reference not set to an instance of an object
Obi.ObiEmitter.UpdateEmitterDistribution () (at Assets/Obi/Scripts/Actors/ObiEmitter.cs:258)
Obi.ObiEmitter.RemoveShape (Obi.ObiEmitterShape shape) (at Assets/Obi/Scripts/Actors/ObiEmitter.cs:154)
Obi.ObiEmitterShape.OnDisable () (at Assets/Obi/Scripts/Emitter/ObiEmitterShape.cs:76)


UPDATE:

I am able to reproduce the error. First I notice that when I uncheck the ObiEmitterShape from the emitter, it still renders the fluid (SimplefluidRenderer). Since I have an object that requires multiple emitterShapes, I created child objects under the single emitter so that I can move them around, etc. When I remove the ObiEmitterShape component from the single emitter object, that's when I get those NullReferenceException errors. To avoid this, should I create multiple emitters and add a single ObiEmitterShape component to them (1 to 1 setup) instead of having one emitter with multiple child objects that have the ObiEmitterShape component attached to them?
Reply
#2
(23-11-2018, 08:50 AM)p3gamer Wrote: Hello,

I have a prefab that contains an emitter, emitter shapes, a solver, and 2d sprites. I noticed that particles were rendering from an emitter shape that I had marked inactive. I also unchecked all emitter shapes and the particles still rendered. I then started to remove emitter shapes (which makes prefab no longer a prefab instance). Now when I am in game mode I get the following errors even though I still have a solver, emitter, emitter shapes.

NullReferenceException: Object reference not set to an instance of an object
Obi.ObiEmitter.OnSolverStepBegin () (at Assets/Obi/Scripts/Actors/ObiEmitter.cs:403)
Obi.ObiSolver.SimulateStep (Single stepTime) (at Assets/Obi/Scripts/Solver/ObiSolver.cs:545)
Obi.ObiSolver.FixedUpdate () (at Assets/Obi/Scripts/Solver/ObiSolver.cs:745)

NullReferenceException: Object reference not set to an instance of an object
Obi.ObiEmitter.UpdateEmitterDistribution () (at Assets/Obi/Scripts/Actors/ObiEmitter.cs:258)
Obi.ObiEmitter.RemoveShape (Obi.ObiEmitterShape shape) (at Assets/Obi/Scripts/Actors/ObiEmitter.cs:154)
Obi.ObiEmitterShape.OnDisable () (at Assets/Obi/Scripts/Emitter/ObiEmitterShape.cs:76)


UPDATE:

I am able to reproduce the error. First I notice that when I uncheck the ObiEmitterShape from the emitter, it still renders the fluid (SimplefluidRenderer). Since I have an object that requires multiple emitterShapes, I created child objects under the single emitter so that I can move them around, etc. When I remove the ObiEmitterShape component from the single emitter object, that's when I get those NullReferenceException errors. To avoid this, should I create multiple emitters and add a single ObiEmitterShape component to them (1 to 1 setup) instead of having one emitter with multiple child objects that have the ObiEmitterShape component attached to them?

Any thoughts as to why these errors keep appearing?
Reply