Struct ColorBlock
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; // Required when Using UI elements.
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
//Changes the button's Disabled color to the new color.
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; // Required when Using UI elements.
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
//Changes the button's Highlighted color to the new color.
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; // Required when Using UI elements.
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
//Changes the button's Normal color to the new color.
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; // Required when Using UI elements.
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
//Changes the button's Pressed color to the new color.
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; // Required when Using UI elements.
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start()
{
//Changes the button's Selected color to the new color.
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
Equality(ColorBlock, ColorBlock)
Declaration
public static bool operator ==(ColorBlock point1, ColorBlock point2)
Parameters
Returns
Inequality(ColorBlock, ColorBlock)
Declaration
public static bool operator !=(ColorBlock point1, ColorBlock point2)
Parameters
Returns