docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct Subframe

    A struct that represents a time within a frame interval.

    Namespace: Unity.LiveCapture
    Assembly: Unity.LiveCapture.dll
    Syntax
    [Serializable]
    public struct Subframe
    Remarks

    The value is stored as a fractional number so that computations are guaranteed to have predictable results and consistent precision.

    Constructors

    Subframe(int, int)

    Creates a new Subframe instance.

    Declaration
    public Subframe(int subframe, int resolution)
    Parameters
    Type Name Description
    int subframe

    The subframe value used to indicate a time somewhere within the duration of the frame. This value is clamped to the range [0, resolution - 1].

    int resolution

    The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero.

    Fields

    DefaultResolution

    The default resolution of the subframe value.

    Declaration
    public const int DefaultResolution = 51200
    Field Value
    Type Description
    int
    Remarks

    Values such as 80 or 100 are typical for SMTPE timecode. This chosen value is the lowest common multiple of 80, 100, and 2048, which allows for exact precision when using those values or smaller powers of 2.

    MaxResolution

    The maximum supported subframe resolution.

    Declaration
    public const int MaxResolution = 65535
    Field Value
    Type Description
    int

    Properties

    Resolution

    The number of possible subframe values in the frame.

    Declaration
    public int Resolution { get; }
    Property Value
    Type Description
    int
    Remarks

    This value is in the range [1, MaxResolution]

    Value

    The subframe within the frame.

    Declaration
    public int Value { get; }
    Property Value
    Type Description
    int
    Remarks

    This value is in the range [0, - 1].

    Methods

    AsDouble()

    Gets the subframe value as a double.

    Declaration
    public double AsDouble()
    Returns
    Type Description
    double

    The subframe value in the range [0, 1].

    AsFloat()

    Gets the subframe value as a float.

    Declaration
    public float AsFloat()
    Returns
    Type Description
    float

    The subframe value in the range [0, 1].

    CompareTo(object)

    Compares this instance to a specified object and returns an indication of their relative values.

    Declaration
    public int CompareTo(object obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with this instance.

    Returns
    Type Description
    int

    A signed number indicating the relative values of this instance and obj. * Returns a negative value when obj is not a valid Subframe instance or this instance is less than obj. * Returns zero when this instance is the same as obj. * Returns a positive value when this instance is greater than obj.

    CompareTo(Subframe)

    Compares this instance to a specified Subframe and returns an indication of their relative values.

    Declaration
    public int CompareTo(Subframe other)
    Parameters
    Type Name Description
    Subframe other

    The value to compare with this instance.

    Returns
    Type Description
    int

    A signed number indicating the relative values of this instance and other. * Returns a negative value when this instance is less than other. * Returns zero when this instance is the same as other. * Returns a positive value when this instance is greater than other.

    Equals(object)

    Returns a value indicating whether this instance is equal to a specified object.

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

    An object to compare with this instance.

    Returns
    Type Description
    bool

    true if obj is an instance of Subframe and equals the value of this instance; otherwise, false.

    Overrides
    ValueType.Equals(object)

    Equals(Subframe)

    Returns a value indicating whether this instance is equal to a specified Subframe.

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

    A value to compare with this instance.

    Returns
    Type Description
    bool

    true if other has the same value as this instance; otherwise, false.

    FromDouble(double, int)

    Creates a new Subframe value from a double.

    Declaration
    public static Subframe FromDouble(double subframe, int resolution = 51200)
    Parameters
    Type Name Description
    double subframe

    A subframe value used to indicate a time somewhere within the duration of the frame. It is clamped to the range [0, 1].

    int resolution

    The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero.

    Returns
    Type Description
    Subframe

    A new Subframe that represents the given frame time.

    FromFloat(float, int)

    Creates a new Subframe value from a float.

    Declaration
    public static Subframe FromFloat(float subframe, int resolution = 51200)
    Parameters
    Type Name Description
    float subframe

    A subframe value used to indicate a time somewhere within the duration of the frame. It is clamped to the range [0, 1].

    int resolution

    The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero.

    Returns
    Type Description
    Subframe

    A new Subframe that represents the given frame time.

    GetHashCode()

    Returns the hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    The hash code for this instance.

    Overrides
    ValueType.GetHashCode()

    ToString()

    Returns a string that represents the current instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents the current instance.

    Overrides
    ValueType.ToString()

    Operators

    operator ==(Subframe, Subframe)

    Determines whether two specified instances of Subframe are equal.

    Declaration
    public static bool operator ==(Subframe a, Subframe b)
    Parameters
    Type Name Description
    Subframe a

    The first instance to compare.

    Subframe b

    The second instance to compare.

    Returns
    Type Description
    bool

    true if a and b represent the same value; otherwise, false.

    explicit operator double(Subframe)

    Gets the value of a Subframe as a double.

    Declaration
    public static explicit operator double(Subframe subframe)
    Parameters
    Type Name Description
    Subframe subframe

    The value to cast.

    Returns
    Type Description
    double

    The subframe value in the range [0, 1].

    explicit operator float(Subframe)

    Gets the value of a Subframe as a float.

    Declaration
    public static explicit operator float(Subframe subframe)
    Parameters
    Type Name Description
    Subframe subframe

    The value to cast.

    Returns
    Type Description
    float

    The subframe value in the range [0, 1].

    operator >(Subframe, Subframe)

    Determines whether one specified Subframe is later than another specified Subframe.

    Declaration
    public static bool operator >(Subframe a, Subframe b)
    Parameters
    Type Name Description
    Subframe a

    The first instance to compare.

    Subframe b

    The second instance to compare.

    Returns
    Type Description
    bool

    true if a is later than b; otherwise, false.

    operator >=(Subframe, Subframe)

    Determines whether one specified Subframe is later than or the same as another specified Subframe.

    Declaration
    public static bool operator >=(Subframe a, Subframe b)
    Parameters
    Type Name Description
    Subframe a

    The first instance to compare.

    Subframe b

    The second instance to compare.

    Returns
    Type Description
    bool

    true if a is later than or the same as b; otherwise, false.

    operator !=(Subframe, Subframe)

    Determines whether two specified instances of Subframe are not equal.

    Declaration
    public static bool operator !=(Subframe a, Subframe b)
    Parameters
    Type Name Description
    Subframe a

    The first instance to compare.

    Subframe b

    The second instance to compare.

    Returns
    Type Description
    bool

    true if a and b do not represent the same value; otherwise, false.

    operator <(Subframe, Subframe)

    Determines whether one specified Subframe is earlier than another specified Subframe.

    Declaration
    public static bool operator <(Subframe a, Subframe b)
    Parameters
    Type Name Description
    Subframe a

    The first instance to compare.

    Subframe b

    The second instance to compare.

    Returns
    Type Description
    bool

    true if a is earlier than b; otherwise, false.

    operator <=(Subframe, Subframe)

    Determines whether one specified Subframe is earlier than or the same as another specified Subframe.

    Declaration
    public static bool operator <=(Subframe a, Subframe b)
    Parameters
    Type Name Description
    Subframe a

    The first instance to compare.

    Subframe b

    The second instance to compare.

    Returns
    Type Description
    bool

    true if a is earlier than or the same as b; otherwise, false.

    In This Article
    Back to top
    Copyright © 2025 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)