XRSessionUpdateParams.cs
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
namespace UnityEngine.XR.ARSubsystems
{
/// <summary>
/// Update parameters for <see cref="XRSessionSubsystem.Update(XRSessionUpdateParams)"/>.
/// </summary>
public struct XRSessionUpdateParams : IEquatable<XRSessionUpdateParams>
{
/// <summary>
/// The current screen orientation
/// </summary>
public ScreenOrientation screenOrientation { get; set; }
/// <summary>
/// The current screen dimensions.
/// </summary>
public Vector2Int screenDimensions { get; set; }
/// <summary>
/// Generates a hash code suitable for use in a Dictionary or HashSet.
/// </summary>
/// <returns>A hash code of this <see cref="XRSessionUpdateParams"/>.</returns>
public override int GetHashCode() => HashCode.Combine(((int)screenOrientation).GetHashCode(), screenDimensions.GetHashCode());
/// <summary>
/// Compares for equality.
/// </summary>
/// <param name="obj">The <c>object</c> to compare against.</param>
/// <returns><c>true</c> if <paramref name="obj"/> is of type <see cref="XRSessionUpdateParams"/> and <see cref="Equals(XRSessionUpdateParams)"/> is <c>true</c>.</returns>
public override bool Equals(object obj) => (obj is XRSessionUpdateParams) && Equals((XRSessionUpdateParams)obj);
/// <summary>
/// Generates a string suitable for debugging.
/// </summary>
/// <returns>A string representation of the update parameters.</returns>
public override string ToString() => $"Screen Orientation: {screenOrientation}, Screen Dimensions: {screenDimensions}";
/// <summary>
/// Compares for equality.
/// </summary>
/// <param name="other">The other <see cref="XRSessionUpdateParams"/> to compare against.</param>
/// <returns><c>true</c> if the other <see cref="XRSessionUpdateParams"/> is equal to this one.</returns>
public bool Equals(XRSessionUpdateParams other) =>
(screenOrientation == other.screenOrientation) &&
screenDimensions.Equals(other.screenDimensions);
/// <summary>
/// Compares for equality.
/// </summary>
/// <param name="lhs">The left-hand side of the comparison.</param>
/// <param name="rhs">The right-hand side of the comparison.</param>
/// <returns>The same as <see cref="Equals(XRSessionUpdateParams)"/>.</returns>
public static bool operator ==(XRSessionUpdateParams lhs, XRSessionUpdateParams rhs) => lhs.Equals(rhs);
/// <summary>
/// Compares for inequality.
/// </summary>
/// <param name="lhs">The left-hand side of the comparison.</param>
/// <param name="rhs">The right-hand side of the comparison.</param>
/// <returns>The negation of <see cref="Equals(XRSessionUpdateParams)"/>.</returns>
public static bool operator !=(XRSessionUpdateParams lhs, XRSessionUpdateParams rhs) => !lhs.Equals(rhs);
}
}