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)

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Constructors
      • FourCC(char, char, char, char)
      • FourCC(int)
      • FourCC(string)
    • Methods
      • Equals(object)
      • Equals(FourCC)
      • FromInt32(int)
      • GetHashCode()
      • ToInt32(FourCC)
      • ToString()
    • Operators
      • operator ==(FourCC, FourCC)
      • implicit operator FourCC(int)
      • implicit operator int(FourCC)
      • operator !=(FourCC, FourCC)
    • Implements
    • Extension Methods
    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)