I’m making a Doom-styled game and I’m having trouble with the enemy sprites.
I’m using a panel to display the sprites and then I made this code to turn the sprite into a texture:
//ignore the array of sprites, pretend there's only one sprite
public Sprite[] spr;
// Update is called once per frame
void Start()
{
var texture = new Texture2D(2, 2, TextureFormat.ARGB32, false);
// set the pixel values
texture = spr[0].texture;
// Apply all SetPixel calls
texture.Apply();
// connect texture to material of GameObject this script is attached to
panel.GetComponent<Renderer>().material.mainTexture = texture;
}
Problem:
My solution so far has been to go into the settings of this new texture and changing from Opaque to Cutout. But how do I do that in the script?
