A game about forced loneliness, made by TACStudios
1using System;
2using UnityEngine;
3
4namespace UnityEditor.U2D.Common.Path.GUIFramework
5{
6 /// <summary>
7 /// Represents a default generic UI control.
8 /// </summary>
9 internal class GenericDefaultControl : DefaultControl
10 {
11 /// <summary>
12 /// Func for GetPosition
13 /// </summary>
14 public Func<IGUIState, Vector3> position;
15 /// <summary>
16 /// Func for GetForward
17 /// </summary>
18 public Func<IGUIState, Vector3> forward;
19 /// <summary>
20 /// Func for GetUp
21 /// </summary>
22 public Func<IGUIState, Vector3> up;
23 /// <summary>
24 /// Func for GetRight
25 /// </summary>
26 public Func<IGUIState, Vector3> right;
27 /// <summary>
28 /// Func for GetUserData
29 /// </summary>
30 public Func<IGUIState, object> userData;
31
32 /// <summary>
33 /// Initializes and returns an instance of GenericDefaultControl
34 /// </summary>
35 /// <param name="name">The name of the generic default control.</param>
36 public GenericDefaultControl(string name) : base(name)
37 {
38 }
39
40 /// <summary>
41 /// Gets the distance from the Scene view camera to the control.
42 /// </summary>
43 /// <param name="guiState">The current state of the custom editor.</param>
44 /// <param name="index">The Index</param>
45 /// <returns>The distance from the Scene view camera to the control.</returns>
46 protected override Vector3 GetPosition(IGUIState guiState, int index)
47 {
48 if (position != null)
49 return position(guiState);
50
51 return base.GetPosition(guiState, index);
52 }
53
54 /// <summary>
55 /// Gets the forward vector of the control.
56 /// </summary>
57 /// <param name="guiState">The current state of the custom editor.</param>
58 /// <param name="index">The Index</param>
59 /// <returns>Returns the generic control's forward vector.</returns>
60 protected override Vector3 GetForward(IGUIState guiState, int index)
61 {
62 if (forward != null)
63 return forward(guiState);
64
65 return base.GetForward(guiState, index);
66 }
67
68 /// <summary>
69 /// Gets the up vector of the control.
70 /// </summary>
71 /// <param name="guiState">The current state of the custom editor.</param>
72 /// <param name="index">The Index</param>
73 /// <returns>Returns the generic control's up vector.</returns>
74 protected override Vector3 GetUp(IGUIState guiState, int index)
75 {
76 if (up != null)
77 return up(guiState);
78
79 return base.GetUp(guiState, index);
80 }
81
82 /// <summary>
83 /// Gets the right vector of the control.
84 /// </summary>
85 /// <param name="guiState">The current state of the custom editor.</param>
86 /// <param name="index">The Index</param>
87 /// <returns>Returns the generic control's right vector.</returns>
88 protected override Vector3 GetRight(IGUIState guiState, int index)
89 {
90 if (right != null)
91 return right(guiState);
92
93 return base.GetRight(guiState, index);
94 }
95
96 /// <summary>
97 /// Gets the control's user data.
98 /// </summary>
99 /// <param name="guiState">The current state of the custom editor.</param>
100 /// <param name="index">The Index</param>
101 /// <returns>Returns the user data</returns>
102 protected override object GetUserData(IGUIState guiState, int index)
103 {
104 if (userData != null)
105 return userData(guiState);
106
107 return base.GetUserData(guiState, index);
108 }
109 }
110}