docs.unity.cn
    Show / Hide Table of Contents

    Struct ColorBlock

    Namespace: UnityEngine.UI
    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
    Single

    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
    Single

    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
    Boolean
    Overrides
    ValueType.Equals(Object)

    Equals(ColorBlock)

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

    GetHashCode()

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

    Operators

    Equality(ColorBlock, ColorBlock)

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

    Inequality(ColorBlock, ColorBlock)

    Declaration
    public static bool operator !=(ColorBlock point1, ColorBlock point2)
    Parameters
    Type Name Description
    ColorBlock point1
    ColorBlock point2
    Returns
    Type Description
    Boolean
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on 12 June 2023