ive setup an offscreen camera and texture with an image which i use a render texture source for a directional light (flare) in my main scene.
all is well except when i first open unity it appears as a white square when i run. if i go into the flare properties and toggle ‘Use Light Color’ on and off (just click it twice) then run my app the flare appears properly - and continues working thereafter, until i close unity and re-open it.
not sure why it requires being ‘touched’ to work so am trying to find a way to do that thru script during initialization.
so heres the question: how can i get a reference to a flares properties so i can toggle the ‘Use Light Color’ property in my script? i’ve tried casting down thru the chain to the flare but no properties come up.
I had that “white square” problem before, but it turned out to be something fairly simple that I had forgotten to set up. So the “touching” actually isn’t necessary, though I can’t remember what the problem was…something in the render settings maybe? Not very helpful, sorry…
do you by chance know how to reference a flares properties thru code? about all i seem to be able to access is the flares name which isnt much help… all my attempts at casting/finding/etc return null… if i could reach the Elements array i think could work around this bug.
Not offhand…not everything is scriptable, so it might not be possible. But like I said, I don’t think this is a bug, just something you have set wrong. At least that was the case with me…still can’t remember what the problem was though.
i may very well be doing something wrong but its only a couple of steps so dont see how/where so sent it in thru ‘report a problem’.
heres a project/scene if you want to check it out. note the square on the dir light then toggle the ‘Use Light Color’ property of the ‘Test Flare’ and the sun will appear correctly (until you close/reopen Unity)
hey maybe it will jog your memory for the missing step(s) ;>
Hmm…maybe it is a bug…it just doesn’t like using a render texture for some reason. I’m starting to think it was a halo I had that problem with anyway rather than a flare…
yes, it appears the unity render texture implementation is broken for flares (and possibly some of the other components as well).
i went a different route and manually assigned a dir light flare via gameobject->lens flare and it fails as well if its pointing to a render tex.
if i touch any of the flares properties in the editor during runtime the RT image will suddenly appear correctly and thereafter - too bad theres no way to access a flares properties thru script or could probably script an easy workaround.