summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Editor/AnimationCurveUtilityRecent.cs
blob: 0b44b879adaca3aaa03d5d5b9673702de39c9339 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Reflection;

namespace UMotionEditor
{
	public static class AnimationCurveUtilityRecent
	{
		//********************************************************************************
		// Public Properties
		//********************************************************************************

        public static bool WeightedTangentsImplemented
        {
            get
            {
                #if UNITY_2018_1_OR_NEWER
                return true;
                #else
                return false;
                #endif
            }
        }

		//********************************************************************************
		// Private Properties
		//********************************************************************************
		
		//----------------------
		// Inspector
		//----------------------
		
		//----------------------
		// Internal
		//----------------------

		//********************************************************************************
		// Public Methods
		//********************************************************************************

        public static void SetKeyWeightedMode(ref Keyframe key, int weightedMode)
        {
            #if UNITY_2018_1_OR_NEWER
            key.weightedMode = (WeightedMode)weightedMode;
            #endif
        }

        public static int GetKeyWeightedMode(Keyframe key)
        {
            #if UNITY_2018_1_OR_NEWER
            return (int)key.weightedMode;
            #else
            return 0;
            #endif
        }

        public static void SetKeyLeftWeight(ref Keyframe key, float weight)
        {
            #if UNITY_2018_1_OR_NEWER
            key.inWeight = weight;
            #endif
        }

        public static float GetKeyLeftWeight(Keyframe key)
        {
            #if UNITY_2018_1_OR_NEWER
            return key.inWeight;
            #else
            return 1f / 3f;
            #endif
        }

        public static void SetKeyRightWeight(ref Keyframe key, float weight)
        {
            #if UNITY_2018_1_OR_NEWER
            key.outWeight = weight;
            #endif
        }        

        public static float GetKeyRightWeight(Keyframe key)
        {
            #if UNITY_2018_1_OR_NEWER
            return key.outWeight;
            #else
            return 1f / 3f;
            #endif
        }

        public static void InitializeKeyframe(int frame, float value, float inTangent, float outTangent,  int weightedMode, float leftWeight, float rightWeight, out Keyframe key)
        {
            key = new Keyframe(frame, value, inTangent, outTangent);

            #if UNITY_2018_1_OR_NEWER
            key.weightedMode = (WeightedMode)weightedMode;
            key.inWeight = leftWeight;
            key.outWeight = rightWeight;
            #endif
        }

        //********************************************************************************
        // Private Methods
        //********************************************************************************
    }
}