Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by iSasFTW · Aug 12, 2015 at 05:54 AM · c#camera2dcolorbackground

Change the background color attribute of a camera in C#?

0 Hey! So, I'm working on a 2D game, and I'd need to change the background color of the main camera, but I just can't figure out the syntax. I'm making this game in C# and I'd need to have it change from an OnTriggerEnter2D function. Thanks! :D

PS. Keep in mind, this is a repost, because my other one got closed. There is a background color attribute in the Unity editor, which you can change in a color selection field, but how can I change it in a script in C#? Here is a picture for clarification: The Background attribute. It is blue in this picture.

Comment
Add comment
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

2 Replies

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

Answer by GiyomuGames · Aug 12, 2015 at 05:56 AM

I think this should help you: http://docs.unity3d.com/ScriptReference/Camera-backgroundColor.html

Comment
Add comment · Show 9 · 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 iSasFTW · Aug 13, 2015 at 05:18 AM 0
Share

Thanks so much! Just one thing: Can i replace Color.Blue, Color.Red etc. with a Hex value?

avatar image allenallenallen · Aug 13, 2015 at 05:20 AM 0
Share

Unity doesn't internally support hex BUT what you can do is write the function yourself:

http://answers.unity3d.com/questions/812240/convert-hex-int-to-colorcolor32.html

avatar image iSasFTW · Aug 13, 2015 at 05:31 AM 0
Share

O$$anonymous$$ then, I Probably wouldnt understand how to use that, so I'll stick with the normal colors. I didn't need it to be hex specifically, only I wanted more control from the base colors. Will it work with RGB, or some other more accurate system?

avatar image allenallenallen · Aug 13, 2015 at 05:41 AM 0
Share

What do you mean? The link I gave you gives a function for converting Hex to Colors. RGB is the base color system. I don't think you can get more accurate than that in Unity.

avatar image GiyomuGames · Aug 13, 2015 at 05:45 AM 0
Share

You can use RGB by doing: new Color(Rvalue, Gvalue, Bvalue), you can also put the alpha as a 4th parameter. Please keep in $$anonymous$$d that all values must be between 0 and 1. http://docs.unity3d.com/ScriptReference/Color.html

Show more comments
avatar image
1

Answer by allenallenallen · Aug 12, 2015 at 05:55 AM

This is the syntax:

http://docs.unity3d.com/ScriptReference/Camera-backgroundColor.html

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Randomly Transition Camera Background Color? 2 Answers

Making a camera semi-orthographic 2 Answers

How to move object side to side of screen width 0 Answers

how to controll second camera (MiniMap)? 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