Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by notgaeb · Nov 24, 2013 at 12:24 AM · colorspritessprite rendererunity 4.3

Is there a way to set a sprite's color solid white?

I neeed to set a sprite color to solid white, to the point where it is only recognizable by its silhouette.

The problem is: Setting a sprite's color to white(1.0f, 1.0f, 1.0f) will result in the sprite having it's "natural" color.

Funny thing is, if you set it to black, the effect I get is the one I'm aiming for... Except it's black.

(I'm using Unity's Sprite Renderer).

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jessy · Nov 24, 2013 at 04:52 AM 0
Share

The color is multiplied in; not screened.

avatar image notgaeb · Nov 24, 2013 at 02:54 PM 0
Share

Is there a way to obtain this effect?

4 Replies

· Add your reply
  • Sort: 
avatar image
17
Best Answer

Answer by nyonge · Dec 15, 2013 at 10:05 AM

You could argue that it's a bit hacky, but using a material with a GUI Text Shader is working totally fine for me!

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image notgaeb · Jan 24, 2014 at 11:47 AM 0
Share

It works perfectly fine, indeed! Thanks a lot.

avatar image TheDemiurge · May 04, 2019 at 05:30 PM 1
Share

6 years later, still a good solution. Took me a $$anonymous$$ute because I kept looking in the UI list and missed that there was a GUI there as well.

avatar image kuro_sk · Oct 13, 2021 at 04:18 PM 0
Share

You could argue that it's a bit straightforward, but I love you!

avatar image
13

Answer by ericdl · May 08, 2014 at 04:52 PM

To expand on nyonge's suggestion, here's one way to set a SpriteRenderer's shader to a GUI Text shader at runtime:

 using UnityEngine;
 using System.Collections;
 
 public class myClass : MonoBehaviour {
     private SpriteRenderer myRenderer;
     private Shader shaderGUItext;
     private Shader shaderSpritesDefault;
 
     void Start () {
         myRenderer = gameObject.GetComponent<SpriteRenderer>();
         shaderGUItext = Shader.Find("GUI/Text Shader");
         shaderSpritesDefault = Shader.Find("Sprites/Default"); // or whatever sprite shader is being used
 
     }
 }

To set the sprite to white:

 void whiteSprite() {
     myRenderer.material.shader = shaderGUItext;
     myRenderer.color = Color.white;
 }

And then to set the sprite back to normal:

 void normalSprite() {
     myRenderer.material.shader = shaderSpritesDefault;
     myRenderer.color = Color.white;
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image wlwl2 · Oct 02, 2018 at 09:00 AM 0
Share

Just wanted to say: you are amazing.

avatar image PixelFireXY · Apr 11, 2020 at 01:13 PM 0
Share

You are a legend! Thank you

Also to simplify I would suggest ins$$anonymous$$d to hard code the name of the original shader you can use this line of code ins$$anonymous$$d: shaderSpritesDefault = myRenderer.material.shader;

avatar image farmerdwight · Apr 28, 2020 at 03:50 AM 0
Share

Thanks, still works in 2020 woo hoo!

avatar image
1

Answer by Cassos · Apr 29, 2020 at 10:43 AM

You could add a mask to the sprite renderer/Image and then create a child that's empty and white, so you just got the white silhouette.

Greetings,

Max

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Spinnernicholas · Nov 26, 2013 at 11:48 PM

You would have to write a new shader to replace the color of every pixel with white.

Then you could replace the default material on the SpriteRenderer.material with a duplicate that has the new shader.

You would have to work around the SpriteRenderer and be careful not to change the default sprite shader and make all your sprites white.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Spinnernicholas · Nov 26, 2013 at 11:55 PM 0
Share

This is definitely a task, but there is some good information out there on shaders in Unity. If you get lost, let me know and I'll see if I can help.

avatar image Spinnernicholas · Nov 26, 2013 at 11:57 PM 0
Share

A technologically simpler solution would just be to create white versions of your sprites.

avatar image notgaeb · Nov 27, 2013 at 12:17 AM 0
Share

Yeah, I ended up doing that since I'm not yet capable of writing a shader. Thanks a lot, though!

avatar image mitrofan1379 · Apr 29, 2020 at 10:03 AM 0
Share

Thank you for posting something like this official

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Translucent sprites appear solid 0 Answers

Sprite not updating color. 1 Answer

Sprite alpha colour not changing via script 1 Answer

bounds.SetMinMax does not do anything 1 Answer

Does anyone know why my sprite isn't showing up? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges