Struct ColorBlock
Assembly: UnityEngine.UI.dll
Syntax
[Serializable]
public struct ColorBlock : IEquatable<ColorBlock>
Fields
defaultColorBlock
Simple getter for a code generated default ColorBlock.
Declaration
public static ColorBlock defaultColorBlock
Field Value
Properties
colorMultiplier
Multiplier applied to colors (allows brightening greater then base color).
Declaration
public float colorMultiplier { get; set; }
Property Value
disabledColor
The disabled color for this color block.
Declaration
public Color disabledColor { get; set; }
Property Value
Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
ColorBlock cb = button.colors;
cb.disabledColor = newColor;
button.colors = cb;
}
}
fadeDuration
How long a color transition between states should take.
Declaration
public float fadeDuration { get; set; }
Property Value
highlightedColor
The highlight color for this color block.
Declaration
public Color highlightedColor { get; set; }
Property Value
Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
ColorBlock cb = button.colors;
cb.highlightedColor = newColor;
button.colors = cb;
}
}
normalColor
The normal color for this color block.
Declaration
public Color normalColor { get; set; }
Property Value
Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
ColorBlock cb = button.colors;
cb.normalColor = newColor;
button.colors = cb;
}
}
pressedColor
The pressed color for this color block.
Declaration
public Color pressedColor { get; set; }
Property Value
Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
ColorBlock cb = button.colors;
cb.pressedColor = newColor;
button.colors = cb;
}
}
selectedColor
The selected color for this color block.
Declaration
public Color selectedColor { get; set; }
Property Value
Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
ColorBlock cb = button.colors;
cb.selectedColor = newColor;
button.colors = cb;
}
}
Methods
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
object |
obj |
|
Returns
Overrides
Equals(ColorBlock)
Declaration
public bool Equals(ColorBlock other)
Parameters
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
Operators
operator ==(ColorBlock, ColorBlock)
Declaration
public static bool operator ==(ColorBlock point1, ColorBlock point2)
Parameters
Returns
operator !=(ColorBlock, ColorBlock)
Declaration
public static bool operator !=(ColorBlock point1, ColorBlock point2)
Parameters
Returns
Implements
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.