Struct FrameTime
A struct that represents a time relative to a frame sequence.
Namespace: Unity.LiveCapture
Assembly: Unity.LiveCapture.dll
Syntax
[Serializable]
public struct FrameTime
Constructors
FrameTime(int, Subframe)
Creates a new Frame
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 readonly int FrameNumber { get; }
Property Value
Type | Description |
---|---|
int |
Subframe
The time within the frame.
Declaration
public readonly 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 readonly FrameTime Ceil()
Returns
CompareTo(object)
Compares this instance to a specified object and returns an indication of their relative values.
Declaration
public readonly 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 Frame
Declaration
public readonly int CompareTo(FrameTime other)
Parameters
Type | Name | Description |
---|---|---|
Frame |
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 readonly 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 Frame
Declaration
public readonly bool Equals(FrameTime other)
Parameters
Type | Name | Description |
---|---|---|
Frame |
other | A value to compare with this instance. |
Returns
Floor()
Gets the frame time rounded down to the start of the current frame.
Declaration
public readonly FrameTime Floor()
Returns
FromFrameTime(double, int)
Creates a new Frame
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
FromSeconds(FrameRate, double, int)
Creates a new Frame
Declaration
public static FrameTime FromSeconds(FrameRate frameRate, double time, int subframeResolution = 51200)
Parameters
Type | Name | Description |
---|---|---|
Frame |
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 |
---|---|
Frame |
A new Frame |
Remarks
The input time is clamped to the range [-Max
GetHashCode()
Returns the hash code for this instance.
Declaration
public override readonly 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 Frame
Declaration
public static double MaxRepresentableSeconds(FrameRate frameRate)
Parameters
Type | Name | Description |
---|---|---|
Frame |
frameRate | The frame rate of the frame sequence. |
Returns
Remap(FrameTime, FrameRate, FrameRate)
Converts a Frame
Declaration
public static FrameTime Remap(FrameTime frameTime, FrameRate srcRate, FrameRate dstRate)
Parameters
Type | Name | Description |
---|---|---|
Frame |
frameTime | The frame time to remap. |
Frame |
srcRate | The original frame rate. |
Frame |
dstRate | The frame rate to convert to. |
Returns
Type | Description |
---|---|
Frame |
A new Frame |
Exceptions
Type | Condition |
---|---|
Overflow |
Thrown if the resulting value is outside the range representable
by the Frame |
Round()
Gets the frame time rounded to the nearest start of a frame.
Declaration
public readonly FrameTime Round()
Returns
Remarks
Subframe values exactly half way in a frame are rounded towards negative infinity.
ToSeconds(FrameRate)
Declaration
public readonly double ToSeconds(FrameRate frameRate)
Parameters
Type | Name | Description |
---|---|---|
Frame |
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 readonly string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current instance. |
Overrides
Operators
operator +(FrameTime, FrameTime)
Calculates the sum of two specified Frame
Declaration
public static FrameTime operator +(FrameTime a, FrameTime b)
Parameters
Returns
Type | Description |
---|---|
Frame |
The sum of |
Exceptions
Type | Condition |
---|---|
Overflow |
Thrown if the resulting value is outside the range representable
by the Frame |
operator --(FrameTime)
Decrements a Frame
Declaration
public static FrameTime operator --(FrameTime a)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The frame time to Decrement. |
Returns
Type | Description |
---|---|
Frame |
The decremented frame time. |
Exceptions
Type | Condition |
---|---|
Overflow |
Thrown if the resulting value is outside the range representable
by the Frame |
operator ==(FrameTime, FrameTime)
Indicates whether two specified instances of Frame
Declaration
public static bool operator ==(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
explicit operator double(FrameTime)
Declaration
public static explicit operator double(FrameTime rate)
Parameters
Type | Name | Description |
---|---|---|
Frame |
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 |
---|---|---|
Frame |
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 |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator >=(FrameTime, FrameTime)
Declaration
public static bool operator >=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator ++(FrameTime)
Increments a Frame
Declaration
public static FrameTime operator ++(FrameTime a)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The frame time to increment. |
Returns
Type | Description |
---|---|
Frame |
The incremented frame time. |
Exceptions
Type | Condition |
---|---|
Overflow |
Thrown if the resulting value is outside the range representable
by the Frame |
operator !=(FrameTime, FrameTime)
Indicates whether two specified instances of Frame
Declaration
public static bool operator !=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator <(FrameTime, FrameTime)
Declaration
public static bool operator <(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator <=(FrameTime, FrameTime)
Indicates whether one specified Frame
Declaration
public static bool operator <=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator -(FrameTime, FrameTime)
Calculates the difference between two specified Frame
Declaration
public static FrameTime operator -(FrameTime a, FrameTime b)
Parameters
Returns
Type | Description |
---|---|
Frame |
The subtraction of |
Exceptions
Type | Condition |
---|---|
Overflow |
Thrown if the resulting value is outside the range representable
by the Frame |