Struct FrameTime
A struct that represents a time relative to a frame sequence, with an optional subframe value.
Namespace: Unity.LiveCapture
Assembly: Unity.LiveCapture.dll
Syntax
[Serializable]
public struct FrameTime
Constructors
FrameTime(int, Subframe)
Creates a new FrameTime instance.
Declaration
public FrameTime(int frameNumber, Subframe subframe = default)
Parameters
Type | Name | Description |
---|---|---|
int | frameNumber | The number of the frame in the sequence. |
Subframe | subframe | The subframe value used to indicate a time somewhere within the duration of the frame. |
Properties
FrameNumber
The number of the frame in the sequence.
Declaration
public int FrameNumber { get; }
Property Value
Type | Description |
---|---|
int |
Subframe
The time within the frame.
Declaration
public Subframe Subframe { get; }
Property Value
Type | Description |
---|---|
Subframe |
Methods
Ceil()
Gets the frame time rounded up to the start of the next frame.
Declaration
public FrameTime Ceil()
Returns
Type | Description |
---|---|
FrameTime | A FrameTime with no subframe component. |
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 |
CompareTo(FrameTime)
Compares this instance to a specified FrameTime and returns an indication of their relative values.
Declaration
public int CompareTo(FrameTime other)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | other | The value to compare with this instance. |
Returns
Type | Description |
---|---|
int | A signed number indicating the relative values of this instance and |
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 |
Overrides
Equals(FrameTime)
Returns a value indicating whether this instance is equal to a specified FrameTime.
Declaration
public bool Equals(FrameTime other)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | other | A value to compare with this instance. |
Returns
Type | Description |
---|---|
bool | true if |
Floor()
Gets the frame time rounded down to the start of the current frame.
Declaration
public FrameTime Floor()
Returns
Type | Description |
---|---|
FrameTime | A FrameTime with no subframe component. |
FromFrameTime(double, int)
Creates a new FrameTime instance from a frame time.
Declaration
public static FrameTime FromFrameTime(double frameTime, int subframeResolution = 51200)
Parameters
Type | Name | Description |
---|---|---|
double | frameTime | The frame time with the frame number in the integer part and the subframe in the decimal part. |
int | subframeResolution | 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 |
---|---|
FrameTime | A new FrameTime that represents the given frame time. |
FromSeconds(FrameRate, double, int)
Creates a new FrameTime instance from a time in seconds and a frame rate.
Declaration
public static FrameTime FromSeconds(FrameRate frameRate, double time, int subframeResolution = 51200)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | frameRate | The frame rate of the frame sequence. |
double | time | The time in seconds. |
int | subframeResolution | 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 |
---|---|
FrameTime | A new FrameTime that represents the given time, or default
if |
Remarks
The input time is clamped to the range [-MaxRepresentableSeconds(FrameRate), MaxRepresentableSeconds(FrameRate)] defined for the provided FrameRate.
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code for this instance. |
Overrides
MaxRepresentableSeconds(FrameRate)
Calculates the maximum length of a frame sequence in seconds that can be represented by a FrameTime.
Declaration
public static double MaxRepresentableSeconds(FrameRate frameRate)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | frameRate | The frame rate of the frame sequence. |
Returns
Type | Description |
---|---|
double | The maximum time in seconds, or default if |
Remap(FrameTime, FrameRate, FrameRate)
Converts a FrameTime in a frame sequence with a given FrameRate to a time in a frame sequence with a different FrameTime.
Declaration
public static FrameTime Remap(FrameTime frameTime, FrameRate srcRate, FrameRate dstRate)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | frameTime | The frame time to remap. |
FrameRate | srcRate | The original frame rate. |
FrameRate | dstRate | The frame rate to convert to. |
Returns
Type | Description |
---|---|
FrameTime | A new FrameTime remapped to the the target frame rate, or default
if |
Exceptions
Type | Condition |
---|---|
OverflowException | Thrown if the resulting value is outside the range representable by the FrameTime type. |
Round()
Gets the frame time rounded to the nearest start of a frame.
Declaration
public FrameTime Round()
Returns
Type | Description |
---|---|
FrameTime | A FrameTime with no subframe component. |
Remarks
Subframe values exactly half way in a frame are rounded towards negative infinity.
ToSeconds(FrameRate)
Declaration
public double ToSeconds(FrameRate frameRate)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | frameRate | The frame rate of the frame sequence. |
Returns
Type | Description |
---|---|
double | The time in seconds since the start of the frame sequence, or default
if |
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
Operators
operator +(FrameTime, FrameTime)
Calculates the sum of two specified FrameTime values.
Declaration
public static FrameTime operator +(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first frame time. |
FrameTime | b | The second frame time. |
Returns
Type | Description |
---|---|
FrameTime | The sum of |
Exceptions
Type | Condition |
---|---|
OverflowException | Thrown if the resulting value is outside the range representable by the FrameTime type. |
operator --(FrameTime)
Decrements a FrameTime by a single frame.
Declaration
public static FrameTime operator --(FrameTime a)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The frame time to Decrement. |
Returns
Type | Description |
---|---|
FrameTime | The decremented frame time. |
Exceptions
Type | Condition |
---|---|
OverflowException | Thrown if the resulting value is outside the range representable by the FrameTime type. |
operator ==(FrameTime, FrameTime)
Determines whether two specified instances of FrameTime are equal.
Declaration
public static bool operator ==(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
explicit operator double(FrameTime)
Declaration
public static explicit operator double(FrameTime rate)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | rate | The value to cast. |
Returns
Type | Description |
---|---|
double | The frame time with the frame number in the integer part and the subframe in the decimal part. |
explicit operator float(FrameTime)
Declaration
public static explicit operator float(FrameTime rate)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | rate | The value to cast. |
Returns
Type | Description |
---|---|
float | The frame time with the frame number in the integer part and the subframe in the decimal part. |
operator >(FrameTime, FrameTime)
Declaration
public static bool operator >(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
operator >=(FrameTime, FrameTime)
Determines whether one specified FrameTime is later than or the same as another specified FrameTime.
Declaration
public static bool operator >=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
operator ++(FrameTime)
Increments a FrameTime by a single frame.
Declaration
public static FrameTime operator ++(FrameTime a)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The frame time to increment. |
Returns
Type | Description |
---|---|
FrameTime | The incremented frame time. |
Exceptions
Type | Condition |
---|---|
OverflowException | Thrown if the resulting value is outside the range representable by the FrameTime type. |
operator !=(FrameTime, FrameTime)
Determines whether two specified instances of FrameTime are not equal.
Declaration
public static bool operator !=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool | true if |
operator <(FrameTime, FrameTime)
Declaration
public static bool operator <(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
operator <=(FrameTime, FrameTime)
Determines whether one specified FrameTime is earlier than or the same as another specified FrameTime.
Declaration
public static bool operator <=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool | true if |
operator -(FrameTime, FrameTime)
Calculates the difference between two specified FrameTime values.
Declaration
public static FrameTime operator -(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The frame time. |
FrameTime | b | The frame time to subtract. |
Returns
Type | Description |
---|---|
FrameTime | The difference of |
Exceptions
Type | Condition |
---|---|
OverflowException | Thrown if the resulting value is outside the range representable by the FrameTime type. |