Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 j0ffe · Dec 06, 2014 at 05:12 PM · c#colors

Color value jump to 1000

My color value jump from RGBA(255,41,41,255) to RGBA(1000,0.162,0.162,255) and I have no idea why. It happens at my ELSE were i call .Reset()

 if (attackReady) {
     Debug.Log(projectails.Count);
     if (projectails.Count == 0) {
         projectails.Add ((GameObject)GameObject.Instantiate (weapon, transform.position, Quaternion.identity));
     }
     if (poolCount >= projectails.Count) {
         poolCount = 0;
     }
     if (projectails [poolCount].GetComponent<AttackProjectails> ().inUse) {
         projectails.Add ((GameObject)GameObject.Instantiate (weapon, transform.position, Quaternion.identity));
         poolCount++;
     } 
     else {
         Debug.Log ("WTF; " + Elements.fire);
         projectails [poolCount].GetComponent<AttackProjectails> ().Reset (transform.position, element, dmg, Elements.fire);
         poolCount++;
     }
     attackReady = false;
     StartCoroutine (waitForAttack (coolDown));
 }

My reset function:

 public void Reset(Vector3 pos, Elements.elements element, int dmg, Color color){
     transform.position = pos;
     this.element = element;
     this.dmg = dmg;
     this.color = color;
     GetComponent<SpriteRenderer>().color = color;
     inUse = true;
 }

And my colors:

 public class Elements {
     public enum elements{ FIRE , WATER , EARTH , AIR };
     public static Color fire = new Color (255, 41, 41, 255);
     public static Color water = new Color(62, 79, 255, 255);
     public static Color earth = new Color(116, 88, 15, 255);
     public static Color air = new Color(255, 255, 255, 255);
 }

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 Eric5h5 · Dec 06, 2014 at 05:18 PM 2
Share

Color values range from 0.0-1.0, not 0-255.

avatar image j0ffe · Dec 06, 2014 at 05:21 PM 0
Share

Oh, thanks. I jumped to the conclusion it was 0-255 because that how it's showed in the inspector.

1 Reply

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

Answer by .Talon · Dec 06, 2014 at 05:38 PM

Colors are using float values from 0 to 1 instead of 0 to 255. Divide all color parameters by 255f and you should get the desired color.

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

26 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Making a bubble level (not a game but work tool) 1 Answer

An OS design issue: File types associated with their appropriate programs 1 Answer

How do I make the scene background have a "default" color? 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