- Home /
How to set LightType for Light Cookie in TextureImporter script?
I have a project where I need to import various assets (models/textures) and assemble them programmatically into a prefab.
I'm running into a problem where when importing a Texture2D asset, the TextureImporter class does not include the same options available in the inspector view.
So far, all I can set is the textureType:
public class TextureImportProcessor : AssetPostprocessor
{
public void OnPreprocessTexture()
{
// ...
if(fileImportedName.Contains("Cookie"))
{
textureImporter.textureType = TextureImporterType.Cookie;
}
// ...
}
}
The issue I'm running into is that the Light Type that I see in the inspector is set to Directional, when I need a Spotlight.
Is there any way to set this in a script?
No answer for this in over 4 years? We can't be the only two people having this issue...
Answer by reification_bherrera · Jun 26, 2019 at 06:25 AM
For anyone else who runs across this issue (still happens in 2018.3.5f1) The issue occurs when you don't set the alphaSource properly.
the major things to set are:
importer.textureType = TextureImporterType.Cookie;
importer.alphaSource = TextureImporterAlphaSource.FromGrayScale;
importer.wrapMode = TextureWrapMode.Clamp;