docs.unity3d.com
    Show / Hide Table of Contents

    Struct FourCC

    A four-character code.

    Namespace: UnityEngine.InputSystem.Utilities
    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(Int32)

    Create a FourCC from the given integer.

    Declaration
    public FourCC(int code)
    Parameters
    Type Name Description
    Int32 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
    Boolean

    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
    Boolean

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

    Implements
    IEquatable<T>.Equals(T)

    FromInt32(Int32)

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

    GetHashCode()

    Compute a hash code for the FourCC.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    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
    Int32

    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

    Equality(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
    Boolean

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

    Implicit(Int32 to FourCC)

    Convert the given int into a FourCC.

    Declaration
    public static implicit operator FourCC(int i)
    Parameters
    Type Name Description
    Int32 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(FourCC to Int32)

    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
    Int32

    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.

    Inequality(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
    Boolean

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

    Extension Methods

    InputState.IsIntegerFormat(FourCC)
    In This Article
    • Constructors
      • FourCC(Char, Char, Char, Char)
      • FourCC(Int32)
      • FourCC(String)
    • Methods
      • Equals(Object)
      • Equals(FourCC)
      • FromInt32(Int32)
      • GetHashCode()
      • ToInt32(FourCC)
      • ToString()
    • Operators
      • Equality(FourCC, FourCC)
      • Implicit(Int32 to FourCC)
      • Implicit(FourCC to Int32)
      • Inequality(FourCC, FourCC)
    • Extension Methods
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023