docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct FrameRate

    A struct that stores a frame rate in Hz as a fractional number to avoid imprecision.

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

    Constructors

    FrameRate(int)

    Creates a new FrameRate instance.

    Declaration
    public FrameRate(int frameRate)
    Parameters
    Type Name Description
    int frameRate

    The frame rate in Hz.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if frameRate is negative.

    FrameRate(int, int, bool)

    Creates a new FrameRate instance.

    Declaration
    public FrameRate(int numerator, int denominator, bool isDropFrame)
    Parameters
    Type Name Description
    int numerator

    The fraction numerator.

    int denominator

    The fraction denominator.

    bool isDropFrame

    Should drop frame calculations be performed when converting between clock time and frame time using this frame rate.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if numerator or Denominator is negative.

    Properties

    Denominator

    The frame rate fraction denominator.

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

    FrameInterval

    Gets the length of time between frames in seconds.

    Declaration
    public double FrameInterval { get; }
    Property Value
    Type Description
    double

    IsDropFrame

    Should drop frame calculations be performed when converting between clock time and frame time using this frame rate.

    Declaration
    public bool IsDropFrame { get; }
    Property Value
    Type Description
    bool
    Remarks

    This can only be true for NTSC frame rates.

    IsValid

    Is the frame rate valid.

    Declaration
    public bool IsValid { get; }
    Property Value
    Type Description
    bool

    Numerator

    The frame rate fraction numerator.

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

    Reciprocal

    Gets the reciprocal of the frame rate fraction.

    Declaration
    public FrameRate Reciprocal { get; }
    Property Value
    Type Description
    FrameRate

    Methods

    AsDouble()

    Gets the frame rate as a double.

    Declaration
    public double AsDouble()
    Returns
    Type Description
    double

    The frame rate in Hz.

    AsFloat()

    Gets the frame rate as a float.

    Declaration
    public float AsFloat()
    Returns
    Type Description
    float

    The frame rate in Hz.

    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 FrameRate 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(FrameRate)

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

    Declaration
    public int CompareTo(FrameRate other)
    Parameters
    Type Name Description
    FrameRate 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 FrameRate and equals the value of this instance; otherwise, false.

    Overrides
    ValueType.Equals(object)

    Equals(FrameRate)

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

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

    A value to compare with this instance.

    Returns
    Type Description
    bool

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

    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()

    IsFactorOf(FrameRate)

    Checks if this FrameRate is a factor of another.

    Declaration
    public bool IsFactorOf(FrameRate other)
    Parameters
    Type Name Description
    FrameRate other

    The frame rate to compare against.

    Returns
    Type Description
    bool

    true if this frame rate is a factor of other; otherwise, false.

    Remarks

    This is based on the time between frames, so 48 fps is considered a factor of 24 fps.

    IsMultipleOf(FrameRate)

    Checks if this FrameRate is a multiple of another.

    Declaration
    public bool IsMultipleOf(FrameRate other)
    Parameters
    Type Name Description
    FrameRate other

    The frame rate to compare against.

    Returns
    Type Description
    bool

    true if this frame rate is a multiple of other; otherwise, false.

    Remarks

    This is based on the time between frames, so 24 fps is considered a multiple of 48 fps.

    IsNtsc(int, int)

    Checks if a frame rate is an NTSC frame rate (23.976, 29.970, 59.94).

    Declaration
    public static bool IsNtsc(int numerator, int denominator)
    Parameters
    Type Name Description
    int numerator

    The frame rate fraction numerator.

    int denominator

    The frame rate fraction denominator.

    Returns
    Type Description
    bool

    true if the given fraction corresponds to an NTSC frame rate; otherwise, false.

    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 /(FrameRate, FrameRate)

    Computes the division of two FrameRate values.

    Declaration
    public static FrameRate operator /(FrameRate a, FrameRate b)
    Parameters
    Type Name Description
    FrameRate a

    The dividend.

    FrameRate b

    The divisor.

    Returns
    Type Description
    FrameRate

    The quotient.

    Exceptions
    Type Condition
    OverflowException

    Thrown if the resulting frame rate is not representable using the FrameRate type.

    operator ==(FrameRate, FrameRate)

    Determines whether two specified instances of FrameRate are equal.

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

    The first instance to compare.

    FrameRate b

    The second instance to compare.

    Returns
    Type Description
    bool

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

    explicit operator double(FrameRate)

    Gets the value of a FrameRate in Hz as a double.

    Declaration
    public static explicit operator double(FrameRate rate)
    Parameters
    Type Name Description
    FrameRate rate

    The value to cast.

    Returns
    Type Description
    double

    The frame rate in Hz.

    explicit operator float(FrameRate)

    Gets the value of a FrameRate in Hz as a float.

    Declaration
    public static explicit operator float(FrameRate rate)
    Parameters
    Type Name Description
    FrameRate rate

    The value to cast.

    Returns
    Type Description
    float

    The frame rate in Hz.

    operator >(FrameRate, FrameRate)

    Determines whether one specified FrameRate is greater than another specified FrameRate.

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

    The first instance to compare.

    FrameRate b

    The second instance to compare.

    Returns
    Type Description
    bool

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

    operator >=(FrameRate, FrameRate)

    Determines whether one specified FrameRate is greater than or the same as another specified FrameRate.

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

    The first instance to compare.

    FrameRate b

    The second instance to compare.

    Returns
    Type Description
    bool

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

    implicit operator FrameRate(StandardFrameRate)

    Gets the FrameRate that corresponds to a StandardFrameRate value.

    Declaration
    public static implicit operator FrameRate(StandardFrameRate rate)
    Parameters
    Type Name Description
    StandardFrameRate rate

    The standard frame rate.

    Returns
    Type Description
    FrameRate

    The standard frame rate value.

    operator !=(FrameRate, FrameRate)

    Determines whether two specified instances of FrameRate are not equal.

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

    The first instance to compare.

    FrameRate b

    The second instance to compare.

    Returns
    Type Description
    bool

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

    operator <(FrameRate, FrameRate)

    Determines whether one specified FrameRate is less than another specified FrameRate.

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

    The first instance to compare.

    FrameRate b

    The second instance to compare.

    Returns
    Type Description
    bool

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

    operator <=(FrameRate, FrameRate)

    Determines whether one specified FrameRate is less than or the same as another specified FrameRate.

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

    The first instance to compare.

    FrameRate b

    The second instance to compare.

    Returns
    Type Description
    bool

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

    operator *(FrameRate, FrameRate)

    Computes the multiple of two FrameRate values.

    Declaration
    public static FrameRate operator *(FrameRate a, FrameRate b)
    Parameters
    Type Name Description
    FrameRate a

    The first operand.

    FrameRate b

    The second operand.

    Returns
    Type Description
    FrameRate

    The multiplied frame rate.

    Exceptions
    Type Condition
    OverflowException

    Thrown if the resulting frame rate is not representable using the FrameRate type.

    Extension Methods

    StandardFrameRateExtensions.TryGetStandardRate(FrameRate, out StandardFrameRate)
    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)