A game about forced loneliness, made by TACStudios
1using UnityEngine;
2
3namespace UnityEditor.U2D.Common.Path.GUIFramework
4{
5 /// <summary>
6 /// Represents the layout of a GUI element in a custom editor.
7 /// </summary>
8 internal struct LayoutData
9 {
10 /// <summary>
11 /// The layout's index.
12 /// </summary>
13 public int index;
14 /// <summary>
15 /// The distance from the layout to the camera.
16 /// </summary>
17 public float distance;
18 /// <summary>
19 /// The layout's world-space position.
20 /// </summary>
21 public Vector3 position;
22 /// <summary>
23 /// The layout's world-space forward vector.
24 /// </summary>
25 public Vector3 forward;
26 /// <summary>
27 /// The layout's world-space up vector.
28 /// </summary>
29 public Vector3 up;
30 /// <summary>
31 /// The layout's world-space right vector.
32 /// </summary>
33 public Vector3 right;
34 /// <summary>
35 /// The layout's user data.
36 /// </summary>
37 public object userData;
38
39 /// <summary>
40 /// Zero definition of LayoutData.
41 /// </summary>
42 public static readonly LayoutData zero = new LayoutData() { index = 0, distance = float.MaxValue, position = Vector3.zero, forward = Vector3.forward, up = Vector3.up, right = Vector3.right };
43
44 /// <summary>
45 /// Gets the layout that is closest to the camera,
46 /// </summary>
47 /// <param name="currentData">The current layout.</param>
48 /// <param name="newData">The new layout to compare with.</param>
49 /// <returns>Returns the closest layout to the camera. If `currentData` is closest to the camera, returns `currentData`. Otherwise, if `newData` is closest to the camera, returns `newData`.</returns>
50 public static LayoutData Nearest(LayoutData currentData, LayoutData newData)
51 {
52 if (newData.distance <= currentData.distance)
53 return newData;
54
55 return currentData;
56 }
57 }
58}