forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtensions.cs
More file actions
28 lines (25 loc) · 983 Bytes
/
Extensions.cs
File metadata and controls
28 lines (25 loc) · 983 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
namespace HoloToolkit.Unity
{
/// <summary>
/// A class with general purpose extensions methods.
/// </summary>
public static class Extensions
{
/// <summary>
/// Returns the absolute duration of the curve from first to last key frame
/// </summary>
/// <param name="curve">The animation curve to check duration of.</param>
/// <returns>Returns 0 if the curve is null or has less than 1 frame, otherwise returns time difference between first and last frame.</returns>
public static float Duration(this AnimationCurve curve)
{
if (curve == null || curve.length <= 1)
{
return 0.0f;
}
return Mathf.Abs(curve[curve.length - 1].time - curve[0].time);
}
}
}