You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <para>The <see cref="Axis"/> logs the <see cref="Time.frameCount"/> and <see cref="Time.unscaledTime"/> whenever <see cref="Value"/> is set.</para>
87
85
/// </summary>
88
-
/// <param name="value">The value to set <see cref="Value"/> to.</param>
86
+
/// <param name="value">The value to set.</param>
89
87
publicvoidSetValue(floatvalue)
90
88
{
91
89
SetValue(value,true);
92
90
}
93
91
94
92
/// <summary>
95
-
/// Set the <see cref="Axis"/> value.
93
+
/// Sets <see cref="Axis"/> value.
96
94
/// <para>The <see cref="Axis"/> logs the <see cref="Time.frameCount"/> and <see cref="Time.unscaledTime"/> whenever <see cref="Value"/> is set.</para>
97
95
/// <para>It is strongly recommended not to set the <paramref name="invoke"/> parameter to false, unless you know what you are doing.
98
96
/// Other classes such as <see cref="TwinAxes"/> use the <see cref="OnValueChanged"/> event to monitor their instances of <see cref="Axis"/> for value changes.</para>
99
97
/// </summary>
100
-
/// <param name="value">The value to set <see cref="Value"/> to.</param>
101
-
/// <param name="invoke">Invokes <see cref="OnValueChanged"/> if true.</param>
98
+
/// <param name="value">The value to set.</param>
99
+
/// <param name="invoke">Invokes <see cref="OnValueChanged"/> if set to true.</param>
102
100
publicvoidSetValue(floatvalue,boolinvoke=true)
103
101
{
104
-
if(value>0f)
102
+
if(value!=Value)
105
103
{
106
-
if(!Positive)
104
+
if(value>0f)
107
105
{
108
-
positiveFrame=Time.frameCount;
109
-
positiveTime=Time.unscaledTime;
106
+
if(!Positive)
107
+
{
108
+
positiveFrame=Time.frameCount;
109
+
positiveTime=Time.unscaledTime;
110
+
}
110
111
}
111
-
}
112
-
elseif(value<0f)
113
-
{
114
-
if(!Negative)
112
+
elseif(value<0f)
115
113
{
116
-
negativeFrame=Time.frameCount;
117
-
negativeTime=Time.unscaledTime;
114
+
if(!Negative)
115
+
{
116
+
negativeFrame=Time.frameCount;
117
+
negativeTime=Time.unscaledTime;
118
+
}
118
119
}
119
-
}
120
-
else
121
-
{
122
-
if(!Neutral)
120
+
else
123
121
{
124
-
neutralFrame=Time.frameCount;
125
-
neutralTime=Time.unscaledTime;
122
+
if(!Neutral)
123
+
{
124
+
neutralFrame=Time.frameCount;
125
+
neutralTime=Time.unscaledTime;
126
+
}
126
127
}
128
+
Value=value;
129
+
if(!set)
130
+
set=true;
131
+
if(invoke)
132
+
OnValueChanged?.Invoke(Value);
127
133
}
128
-
Value=value;
129
-
if(!set)
130
-
set=true;
131
-
if(invoke)
132
-
OnValueChanged?.Invoke(Value);
133
134
}
134
135
135
136
/// <summary>
136
-
/// Set <see cref="Value"/> to neutral (0f).
137
+
/// Sets <see cref="Value"/> to "neutral" (0f).
137
138
/// <para>The <see cref="Axis"/> logs the <see cref="Time.frameCount"/> and <see cref="Time.unscaledTime"/> whenever <see cref="Value"/> is set.</para>
138
139
/// </summary>
139
140
publicvoidSetNeutral()
140
141
{
141
142
SetValue(0f);
142
143
}
143
144
145
+
/// <summary>
146
+
/// Tie the <see cref="Axis"/> to an <see cref="InputAction"/>.
147
+
/// </summary>
148
+
/// <param name="action">The <see cref="InputAction"/> to attach to the <see cref="Axis"/>.</param>
149
+
publicvoidRegisterInputAction(InputActionaction)
150
+
{
151
+
if(action==null)
152
+
thrownewSystem.ArgumentNullException("action");
153
+
if(action.expectedControlType!="Axis")
154
+
thrownewSystem.ArgumentException("InputAction "+action.name+" does not have an expected Axis control type.");
/// Returns for how many frames <see cref="Value"/> has been positive, if it currently is. Returns -1 otherwise.
148
162
/// </summary>
149
163
/// <returns>
150
164
/// How many frames <see cref="Value"/> has been positive, if it currently is. If <see cref="Value"/> is currently not positive, this method will return -1.
151
-
/// This method will also always return -1 if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.
165
+
/// <para>This method will also always return -1 if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.</para>
/// Returns for how many seconds <see cref="Value"/> has been positive, if it currently is. Returns -1f otherwise.
163
177
/// </summary>
164
178
/// <returns>
165
179
/// How many seconds <see cref="Value"/> has been positive, if it currently is. If <see cref="Value"/> is currently not positive, this method will return -1f.
166
-
/// This method will also always return -1f if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.
180
+
/// <para>This method will also always return -1f if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.</para>
/// Returns for how many frames <see cref="Value"/> has been neutral (0f), if it currently is. Returns -1 otherwise.
178
192
/// </summary>
179
193
/// <returns>
180
194
/// How many frames <see cref="Value"/> has been neutral, if it currently is. If <see cref="Value"/> is currently not neutral, this method will return -1.
181
-
/// This method will also always return -1 if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.
195
+
/// <para>This method will also always return -1 if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.</para>
/// Returns for how many seconds <see cref="Value"/> has been neutral (0f), if it currently is. Returns -1f otherwise.
193
207
/// </summary>
194
208
/// <returns>
195
209
/// How many seconds <see cref="Value"/> has been neutral, if it currently is. If <see cref="Value"/> is currently not neutral, this method will return -1f.
196
-
/// This method will also always return -1f if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.
210
+
/// <para>This method will also always return -1f if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.</para>
/// Returns for how many frames <see cref="Value"/> has been negative, if it currently is. Returns -1 otherwise.
208
222
/// </summary>
209
223
/// <returns>
210
224
/// How many frames <see cref="Value"/> has been negative, if it currently is. If <see cref="Value"/> is currently not negative, this method will return -1.
211
-
/// This method will also always return -1 if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.
225
+
/// <para>This method will also always return -1 if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.</para>
/// Returns for how many seconds <see cref="Value"/> has been negative, if it currently is. Returns -1f otherwise.
223
237
/// </summary>
224
238
/// <returns>
225
239
/// How many seconds <see cref="Value"/> has been negative, if it currently is. If <see cref="Value"/> is currently not negative, this method will return -1f.
226
-
/// This method will also always return -1f if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.
240
+
/// <para>This method will also always return -1f if <see cref="SetValue(float)"/> or <see cref="SetNeutral"/> have never been called.</para>
0 commit comments