docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct ColorBlock

    Implements
    IEquatable<ColorBlock>
    Inherited Members
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.UI
    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
    Type Description
    ColorBlock

    Properties

    colorMultiplier

    Multiplier applied to colors (allows brightening greater then base color).

    Declaration
    public float colorMultiplier { get; set; }
    Property Value
    Type Description
    float

    disabledColor

    The disabled color for this color block.

    Declaration
    public Color disabledColor { get; set; }
    Property Value
    Type Description
    Color
    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
    Type Description
    float

    highlightedColor

    The highlight color for this color block.

    Declaration
    public Color highlightedColor { get; set; }
    Property Value
    Type Description
    Color
    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
    Type Description
    Color
    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
    Type Description
    Color
    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
    Type Description
    Color
    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
    Type Description
    bool
    Overrides
    ValueType.Equals(object)

    Equals(ColorBlock)

    Declaration
    public bool Equals(ColorBlock other)
    Parameters
    Type Name Description
    ColorBlock other
    Returns
    Type Description
    bool

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    Operators

    operator ==(ColorBlock, ColorBlock)

    Declaration
    public static bool operator ==(ColorBlock point1, ColorBlock point2)
    Parameters
    Type Name Description
    ColorBlock point1
    ColorBlock point2
    Returns
    Type Description
    bool

    operator !=(ColorBlock, ColorBlock)

    Declaration
    public static bool operator !=(ColorBlock point1, ColorBlock point2)
    Parameters
    Type Name Description
    ColorBlock point1
    ColorBlock point2
    Returns
    Type Description
    bool

    Implements

    IEquatable<T>
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)