Change texture type to cookie via script.

So I have a light in my scene with a texture on it… the texture type is a cookie. I can change the lights cookie texture to a new texture via script but it comes out in tiles… so how do I change the second texture type to cookie via script. Thank you.

Ok so I solved my problem for anyone with simular problem in the future. So my light texture needed to be a cookie. But to import a texture and change it to cookie during runtime apparently can’t be done. I managed a work around. I have a public material (shader type… mobile/particles/multiply) I then change the maintexture.

First new alpha image.wrapmode = light.cookie.wrapmode.
Then material.maintexture = alpha image.

Then make a Texture2D = material.maintexture as Texture2D.

Lastly light.cookie = Texture2D.

Light must be spot and have a texture on it at start that is type cookie with wrapmode set to clamp.

Somehow it passes everything through and works perfectly.