docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct FourCC

    A four-character code.

    Implements
    IEquatable<FourCC>
    Namespace: UnityEngine.InputSystem.Utilities
    Assembly: Unity.InputSystem.dll
    Syntax
    public struct FourCC : IEquatable<FourCC>
    Remarks

    A four-character code is a struct containing four byte characters totalling a single int. FourCCs are frequently used in the input system to identify the format of data sent to or from the native backend representing events, input device state or commands sent to input devices.

    Constructors

    FourCC(char, char, char, char)

    Create a FourCC from the given four characters.

    Declaration
    public FourCC(char a, char b = ' ', char c = ' ', char d = ' ')
    Parameters
    Type Name Description
    char a

    First character.

    char b

    Second character.

    char c

    Third character.

    char d

    Fourth character.

    FourCC(int)

    Create a FourCC from the given integer.

    Declaration
    public FourCC(int code)
    Parameters
    Type Name Description
    int code

    FourCC code represented as an int. Character order is little endian. "ABCD" is stored with A in the highest order 8 bits and D in the lowest order 8 bits.

    Remarks

    This method does not actually verify whether the four characters in the code are printable.

    FourCC(string)

    Create a FourCC from the given string.

    Declaration
    public FourCC(string str)
    Parameters
    Type Name Description
    string str

    A string with four characters or less but with at least one character.

    Exceptions
    Type Condition
    ArgumentException

    str is empty or has more than four characters.

    ArgumentNullException

    str is null.

    Methods

    Equals(object)

    Compare the FourCC to the given object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    An object. Can be null.

    Returns
    Type Description
    bool

    True if obj is a FourCC that has the same character code sequence.

    Overrides
    ValueType.Equals(object)

    Equals(FourCC)

    Compare two FourCCs for equality.

    Declaration
    public bool Equals(FourCC other)
    Parameters
    Type Name Description
    FourCC other

    Another FourCC.

    Returns
    Type Description
    bool

    True if the two FourCCs are equal, i.e. have the same exact character codes.

    FromInt32(int)

    Declaration
    public static FourCC FromInt32(int i)
    Parameters
    Type Name Description
    int i
    Returns
    Type Description
    FourCC

    GetHashCode()

    Compute a hash code for the FourCC.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    Simply returns the FourCC converted to an int.

    Overrides
    ValueType.GetHashCode()

    ToInt32(FourCC)

    Declaration
    public static int ToInt32(FourCC fourCC)
    Parameters
    Type Name Description
    FourCC fourCC
    Returns
    Type Description
    int

    ToString()

    Convert the FourCC into a string in the form of "ABCD".

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    String representation of the FourCC.

    Overrides
    ValueType.ToString()

    Operators

    operator ==(FourCC, FourCC)

    Compare two FourCCs for equality.

    Declaration
    public static bool operator ==(FourCC left, FourCC right)
    Parameters
    Type Name Description
    FourCC left

    First FourCC.

    FourCC right

    Second FourCC.

    Returns
    Type Description
    bool

    True if the two FourCCs are equal, i.e. have the same exact character codes.

    implicit operator FourCC(int)

    Convert the given int into a FourCC.

    Declaration
    public static implicit operator FourCC(int i)
    Parameters
    Type Name Description
    int i

    FourCC code represented as an int. Character order is little endian. "ABCD" is stored with A in the highest order 8 bits and D in the lowest order 8 bits.

    Returns
    Type Description
    FourCC

    The FourCC converted from i.

    implicit operator int(FourCC)

    Convert the given FourCC into an int.

    Declaration
    public static implicit operator int(FourCC fourCC)
    Parameters
    Type Name Description
    FourCC fourCC

    A FourCC.

    Returns
    Type Description
    int

    The four characters of the code packed into one int. Character order is little endian. "ABCD" is stored with A in the highest order 8 bits and D in the lowest order 8 bits.

    operator !=(FourCC, FourCC)

    Compare two FourCCs for inequality.

    Declaration
    public static bool operator !=(FourCC left, FourCC right)
    Parameters
    Type Name Description
    FourCC left

    First FourCC.

    FourCC right

    Second FourCC.

    Returns
    Type Description
    bool

    True if the two FourCCs are not equal, i.e. do not have the same exact character codes.

    Implements

    IEquatable<T>

    Extension Methods

    InputState.IsIntegerFormat(FourCC)
    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)