Null Reference Exception when creating a new Flare Asset
Closed this issue · 8 comments
Hey I'm using Unity 2020.2.6f1. If you import your project and run the Sample scene, everything works fine. But as soon as you create some new Flare Assets and set them up in a new scene a bunch of null reference exceptions start happening and the flare doesn't work.
I thought that you didn't set a flare asset to flare launcher or you just set an empty flare asset with no texture to a launcher.
These two situations will sure cause null reference exceptions.
I wonder if you can reply some screen shot so that I can find the question more clearly.
So here is a snapshot of the issue. I create a new flare asset (image in 'Resources/Lensflare'), then assign the necessary scripts to both my scenes light source (URPLensFlareLauncher - with the new lens flare asset attached), and my scene camera (URPLensFlare - with the LensFlare material). Then when I run it, the new lens flare asset I created gets wiped clean/reset (see pic related). However, if I use the Lens Flare Asset you provide in the example folder this never happens.
So here is a snapshot of the issue. I create a new flare asset (image in 'Resources/Lensflare'), then assign the necessary scripts to both my scenes light source (URPLensFlareLauncher - with the new lens flare asset attached), and my scene camera (URPLensFlare - with the LensFlare material). Then when I run it, the new lens flare asset I created gets wiped clean/reset (see pic related). However, if I use the Lens Flare Asset you provide in the example folder this never happens.
Please choose a texture to this asset and add at least one flare block to it, or the launcher can't find any data in flare asset
@Reguluz I'm not sure I was clear enough. The URPFlareAsset Scriptable Object gets reset whenever the game exits play mode or when you save the unity editor.
For instance, I create a fully loaded Flare Asset (pic related):
Then I assign it to my in-game URP Flare Launcher. Then I press play.
When I exit play mode, the URPFlareAsset now looks like this:
So I deleted the URPFlareLauncher +and URPLensFlare scripts, so that just the URPFlareAsset and URPFlareAssetEditor scripts were left. Same thing occurs, when you create a new URPFlareAsset and fill it out with an image and make some field + setting, then you hit play, exit play, the new URPFlareAsset is all reset. So I think in Unity 2020.2 that your editor script is reseting the Scriptable object somehow.
t
@Reguluz I'm not sure I was clear enough. The URPFlareAsset Scriptable Object gets reset whenever the game exits play mode or when you save the unity editor.
For instance, I create a fully loaded Flare Asset (pic related):
Then I assign it to my in-game URP Flare Launcher. Then I press play.
When I exit play mode, the URPFlareAsset now looks like this:
That's so weired. I'll soon check it out. I'm so sorry about that.
So I deleted the URPFlareLauncher +and URPLensFlare scripts, so that just the URPFlareAsset and URPFlareAssetEditor scripts were left. Same thing occurs, when you create a new URPFlareAsset and fill it out with an image and make some field + setting, then you hit play, exit play, the new URPFlareAsset is all reset. So I think in Unity 2020.2 that your editor script is reseting the Scriptable object somehow.
I wonder which version did you use. Did you download the repository or just use the unitypackage I have released?
Hey Reguluz, sorry for the slow response (got distracted by my day job). I downloaded this repo (master) branch. I will check out the unity package!