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 /
  • Help Room /
avatar image
0
Question by Danor · Nov 28, 2015 at 04:06 PM · uiunity5colorbuttonshighlight

After changing multiple buttons highlight color, buttons dissapear on click.

I want to give my players the option of changing some of the menu colors incl the button highlights and even though it took me quite some headscratching i made a function that succesfully changes the highlights of all buttons in my list but there's a weird side effect, now buttons dissapear on click and then briefly show the highlight while re-appearing back to normal state.

I don't understand what's going on at all and there's no errors.

All buttons have the default Color Tint Transition And here's my code:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.UI;
 
 public List<Color> Colors = new List<Color>();
 public List<Button> Buttons = new List<Button>();
 
 public void ButtonHighlights(int colorSelected){
         int count = Buttons.Count;
         while(count != 0){
             count--;
             Button b = Buttons[count].GetComponent<Button>(); 
             ColorBlock cb = b.colors;
             cb.highlightedColor = Colors[colorSelected];
             b.colors = cb;
         }
     }


If anyone has any ideas, please share them! The code is based on code by @PeterMu Link: http://answers.unity3d.com/questions/792008/how-to-change-normal-color-highlighted-color-etc-i.html Thanks in advance.

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
0
Best Answer

Answer by Danor · Dec 02, 2015 at 01:10 AM

I feel really silly now but the problem wasn't script related, i set the A value of the colors in "Colors" list, in the editor to 0 instead of 255 for some reason.

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 DannyMen · Sep 20, 2017 at 02:17 AM

thanks a lot for the commet you save me the night check the alpha chanel

using UnityEngine.UI;

 public Color newColor;

 void Start(){

      Button miBoton = this.GetComponent<Button>(); 
      ColorBlock cb = miBoton.colors;
         cb.highlightedColor = newColor;
      miBoton.colors = cb;        
 }
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

45 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

Related Questions

Buttons not highlighting while dragging 0 Answers

How to change the position of a button? 1 Answer

Buttons not working on click for VR game 0 Answers

how to do on single click fire and on drag appears the joystick and get the input from joystick 0 Answers

HELP ME PLEASE TO FIX MY PROBLEM.. 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