- Home /
How to use unlit texture on UI panel with scripting
Copying an unanswered post from the UI forum:
I'm trying to create a UI panel that alternates between pure black and pure white every frame, and is unaffected by lighting, so the actual displayed pixels will always have RGBA values of (0, 0, 0, 1) or (1, 1, 1, 1). (If you're curious, I'm doing this so I can get precise timing of each frame using optical sensors attached to an external timing computer - this is for a neuroscience experiment so I need better timing than Unity is capable of.)
This seems to be a little more complex than I originally assumed, and after some confused googling I tried creating a new material using an "Unlit/Texture" shader. Then I created a UI panel, set the source image to "None", and dropped the new material onto it. But now it just seems to be white all the time. In my script, I've tried modifying the CanvasRenderer's colour, the Image's colour, and the Image.Materials' colour. None of those seem to change anything.
Do I need to create two custom textures, and attach each to a material, and then through the script change the material attached to the square every time ? This seems a very convoluted way of doing things!
Answer by marcusrwatson · Apr 04, 2016 at 03:43 PM
Never mind I figured out that changing image.material does work fine, I just had a different script error that meant the colour was never being assigned correctly.
Your answer
Follow this Question
Related Questions
Can a UI element create transparency in another under it? 1 Answer
Unlit Transparent Shader causing strange issues 1 Answer
Unlit Shader with Shadows from point lights. 1 Answer
Custom shader on UI Image 1 Answer
What are the difference between between Unlit/color and Sprite/default material shader? 0 Answers