Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by yanndelescaille · Aug 01, 2019 at 05:43 AM · imagecolor change

How can I change color of an Image in script (png source) ?

I made a png image with gimp with one color and transparent. I have include this image in Image UI component in unity. I linked my image to my script, as usual. alt text But I find many ways to change the color on many forums (mainly answers.unity) but none of these work in my project : alt text I know the first one is only if I declared my image as gameObject.

How can I do the color change ?

variable-declaration.png (910 B)
assignation.png (4.3 kB)
Comment
Add comment · Show 5
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 SirPaddow · Aug 01, 2019 at 10:08 AM 0
Share

The correct way to do it is to assign the stepCircle.color (3rd option). What is the problem? From what you show, it should work, so maybe the problem comes from another part of your code?

avatar image yanndelescaille · Aug 02, 2019 at 03:04 AM 0
Share

$$anonymous$$aybe I have a clue : when I go to the unity inspector and change the color like this, it doesn't work either. The only way to change is to add a material, the image disappear for most of all.

alt text

circle-info.png (10.0 kB)
avatar image Casiell yanndelescaille · Aug 02, 2019 at 09:33 AM 1
Share

Is your image black by any chance? Color property is multiplicative in Unity so changing it for black (0, 0, 0) images does nothing as anything times 0 is still 0

avatar image yanndelescaille Casiell · Aug 04, 2019 at 11:59 PM 0
Share

Indeed, my color was black (0, 0, 0). I try with red and blue color, and each color is 0 by default can't change. So I repaint all my images to white. Thank you very much, it works

avatar image SirPaddow yanndelescaille · Aug 02, 2019 at 10:38 AM 0
Share

Another possibility I can think of is if you set the source image within your code, using "myImage.sprite = aSprite;". Then, sometines (I'm not sure if it's a bug or not), changing the other parameters of the image have no effect. A solution is to use "myImage.overrideSprite = aSprite;" ins$$anonymous$$d.

1 Reply

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

Answer by yanndelescaille · Aug 05, 2019 at 12:35 AM

Thanks to @Casiell for the answer. Thanks to @SirPaddow too but I don't try the the sprite.

In the case of peoples can't read the comments, I put the answer here : alt text


answer.png (20.0 kB)
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

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

112 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 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 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 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

Change the button target image alpha 1 Answer

Assign image color values to multiple primitives 2 Answers

to keep the same image color after build to Android 0 Answers

When I try to change the Color of an Image, It will change to the original Image color instead.,When I change the color of an Image, it will show the original source image color instead 1 Answer

How to avoid color multiplication with UI.Graphic.CrossFadeColor? 1 Answer


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