- Home /
Make a sprite have the same color as the main light of the scene
Hi, I'd like to do what it says in the title. I explain: I have the main light of the scene (directional light) which has a color. A sprite also has a color. And here I would like to make the sprite have the same color as the main light. I'm new to Unity and need some help. I need a C# script. BTW, that sprite is in a 3D world. If you're wondering why he does a sprite in a 3D world, it's not a GUI, it's an object in the scene. Is more complex to explain. Thanks.
Change the sprite -> Square $$anonymous$$esh. $$anonymous$$esh have shader. Shader can render object same color(no Color) as Lighting
Thanks! Sorry if I made a dumb question, as you can see I'm new in Unity. Also, sorry for my bad english. :S But how I do that?
Answer by hectorux · Jun 25, 2018 at 03:39 AM
Why dont use a quad instead?, it wil use the same as the sprite, but will have the materials parameters to play with. Also you can change the material of the sprite to standard, and i think it may work. If both doesnt work for you, you can use getComponent().color; to change to the color you want. Use colorUtility to set the color you have in the directional light to the spriteRenderer color. Example: SpriteRenderer sr; Light directionalLight;
sr= getComponent<SpriteRenderer>();
sr.color=directionalLight.color;
Your answer
Follow this Question
Related Questions
How do I make a spotlight make a model play an animation? 2 Answers
Using URP how to make sprites lit by 3D Lights again? 6 Answers
How to move player or character Left right by 14 unit every at button click on mobile 0 Answers
Global Fog Messy Transition Between Objects and Skybox 1 Answer
What does GI stand for? 1 Answer