├── .gitignore ├── Assets ├── AnimationCurve.unity ├── AnimationCurve.unity.meta ├── AnimationCurveTool.cs ├── AnimationCurveTool.cs.meta ├── AnimationCurveToolMod.cs ├── AnimationCurveToolMod.cs.meta ├── Bezier.unity ├── Bezier.unity.meta ├── BezierCurve.cs ├── BezierCurve.cs.meta ├── CurveExtension.cs ├── CurveExtension.cs.meta ├── DragPoint.cs ├── DragPoint.cs.meta ├── GizmoDrawAnimCurve.cs ├── GizmoDrawAnimCurve.cs.meta ├── KeyFramePoint.cs ├── KeyFramePoint.cs.meta ├── KeyFramePoint.prefab ├── KeyFramePoint.prefab.meta ├── KeyframeUtil.cs ├── KeyframeUtil.cs.meta ├── Plugins.meta ├── Plugins │ ├── LeanTween.cs │ └── LeanTween.cs.meta ├── pivotMat.mat └── pivotMat.mat.meta └── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityAnalyticsManager.asset /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | 5 | # Autogenerated VS/MD solution and project files 6 | /*.csproj 7 | /*.unityproj 8 | /*.sln 9 | /*.suo 10 | /*.user 11 | /*.userprefs 12 | /*.pidb 13 | /*.booproj -------------------------------------------------------------------------------- /Assets/AnimationCurve.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/Assets/AnimationCurve.unity -------------------------------------------------------------------------------- /Assets/AnimationCurve.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 357fb809d815443639f2205f470522ca 3 | timeCreated: 1439796637 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/AnimationCurveTool.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using CurveExtended; 4 | 5 | public class AnimationCurveTool : MonoBehaviour { 6 | 7 | public AnimationCurve curve; 8 | 9 | // Use this for initialization 10 | void Start () { 11 | Keyframe[] ks = new Keyframe[3]; 12 | 13 | ks[0] = new Keyframe(0, 0); 14 | ks[0].inTangent = 0; 15 | 16 | ks[1] = new Keyframe(0.5f, 1.0f); 17 | ks[1].inTangent = 45; 18 | ks[1].outTangent = -45; 19 | 20 | ks[2] = new Keyframe(1, 0); 21 | ks[2].inTangent = 200; 22 | 23 | 24 | // ks[0] = KeyframeUtil.GetNew(0, 0, TangentMode.Linear, TangentMode.Stepped); 25 | // ks[1] = KeyframeUtil.GetNew(0.5f, 5.0f, TangentMode.Linear, TangentMode.Stepped); 26 | // ks[2] = KeyframeUtil.GetNew(1, 0, TangentMode.Linear, TangentMode.Stepped); 27 | 28 | // KeyframeUtil.SetKeyBroken(ks[1], false); 29 | // KeyframeUtil.SetKeyTangentMode(ks[1], 0, TangentMode.Linear); 30 | // KeyframeUtil.SetKeyTangentMode(ks[1], 1, TangentMode.Stepped); 31 | 32 | curve = new AnimationCurve(ks); 33 | curve.UpdateAllLinearTangents(); 34 | 35 | Keyframe key = KeyframeUtil.GetNew(0.5f, 1.0f, TangentMode.Editable, TangentMode.Stepped); 36 | key.inTangent = 45; 37 | UpdateKey(1, key); 38 | 39 | // curve.UpdateAllLinearTangents(); 40 | } 41 | 42 | void UpdateKey(int index, Keyframe key) 43 | { 44 | curve.MoveKey(index, key); 45 | } 46 | 47 | // Update is called once per frame 48 | void Update () { 49 | 50 | } 51 | 52 | // public float split = 100; 53 | // 54 | // bool CheckKeyTime(float t0, float t1, out float t) 55 | // { 56 | // Keyframe[] keys = curve.keys; 57 | // for(int i = 0; i < keys.Length; i++){ 58 | // Keyframe key = keys[i]; 59 | // float keyTime = key.time; 60 | // if(keyTime >= t0 && keyTime <= t1){ 61 | // t = key.time; 62 | // return true; 63 | // } 64 | // } 65 | // t = Mathf.NegativeInfinity; 66 | // return false; 67 | // } 68 | 69 | public GizmoDrawAnimCurve gizmoDrawAnimCurve; 70 | 71 | void OnDrawGizmos() 72 | { 73 | if(gizmoDrawAnimCurve != null){ 74 | gizmoDrawAnimCurve.DrawGizmos(curve); 75 | } 76 | // Gizmos.DrawWireSphere(Vector3.zero, 1.0f); 77 | // 78 | // Gizmos.color = Color.red; 79 | // 80 | // float delta = 1.0f / split; 81 | // for(int i = 0; i < split; i++){ 82 | // float t0 = delta * i; 83 | // float v0 = curve.Evaluate(t0); 84 | // 85 | // float t1 = delta * (i+1); 86 | // float v1 = curve.Evaluate(t1); 87 | // 88 | // float t = 0.0f; 89 | // if(CheckKeyTime(t0, t1, out t)){ 90 | // t0 = t1 = t; 91 | // } 92 | // 93 | // Gizmos.DrawLine(new Vector3(t0, v0, 0), new Vector3(t1, v1, 0)); 94 | // } 95 | // 96 | // Keyframe[] keys = curve.keys; 97 | // for(int i = 0; i < keys.Length; i++){ 98 | // Keyframe key = keys[i]; 99 | // Vector3 pos = new Vector3(key.time, key.value, 0); 100 | // Gizmos.DrawWireSphere(pos, 0.05f); 101 | // 102 | //// Vector3 posT = new Vector3(key.time, key.inTangent, 0); 103 | //// Gizmos.DrawWireSphere(posT, 0.05f); 104 | // } 105 | // 106 | //// Debug.Log(keys[1].inTangent + " / "+keys[1].outTangent + " / "+keys[1].tangentMode); 107 | // 108 | // 109 | // Vector3 pos1 = new Vector3(keys[1].time, keys[1].value, 0); 110 | // float inTan = Mathf.Atan( keys[1].inTangent ); 111 | // Vector3 pos1_intangent = pos1 - new Vector3(Mathf.Cos(inTan), Mathf.Sin(inTan), 0); 112 | // Gizmos.color = Color.cyan; 113 | // Gizmos.DrawLine(pos1, pos1_intangent); 114 | } 115 | } 116 | 117 | -------------------------------------------------------------------------------- /Assets/AnimationCurveTool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6537aee1fb1654f559fe3269fef95e86 3 | timeCreated: 1439796649 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AnimationCurveToolMod.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using CurveExtended; 5 | 6 | public class AnimationCurveToolMod : MonoBehaviour { 7 | 8 | public AnimationCurve curve; 9 | 10 | public List keyFramePoints; 11 | 12 | public KeyFramePoint addKeyFramePoint;//debug 13 | 14 | // Use this for initialization 15 | void Start () { 16 | Keyframe[] ks = new Keyframe[keyFramePoints.Count]; 17 | 18 | for(int i = 0; i < ks.Length; i++){ 19 | KeyFramePoint kp = keyFramePoints[i]; 20 | float t = kp.time; 21 | float v = kp.v; 22 | float inT = kp.inTangent; 23 | float outT = kp.outTangent; 24 | ks[i] = new Keyframe(t, v, inT, outT); 25 | } 26 | 27 | curve = new AnimationCurve(ks); 28 | curve.UpdateAllLinearTangents(); 29 | } 30 | 31 | // Update is called once per frame 32 | void Update () { 33 | UpdateAllKeyframePoints(); 34 | } 35 | 36 | void UpdateAllKeyframePoints() 37 | { 38 | for(int i = 0; i < keyFramePoints.Count; i++){ 39 | UpdateKeyframePoint(i, keyFramePoints[i]); 40 | } 41 | } 42 | 43 | void UpdateKeyframePoint(int i, KeyFramePoint kp) 44 | { 45 | float t = kp.time; 46 | float v = kp.v; 47 | float inT = kp.inTangent; 48 | float outT = kp.outTangent; 49 | 50 | // tangentMode 51 | if(i > 0 && kp.inTangentMode == TANGENT_MODE.Linear){ 52 | KeyFramePoint preKp = keyFramePoints[i-1]; 53 | Vector3 inDir = preKp.position - kp.position; 54 | inDir.Normalize(); 55 | inT = inDir.y / inDir.x; 56 | } 57 | if(i < keyFramePoints.Count-1 && kp.outTangentMode == TANGENT_MODE.Linear){ 58 | KeyFramePoint nextKp = keyFramePoints[i+1]; 59 | Vector3 outDir = nextKp.position - kp.position; 60 | outDir.Normalize(); 61 | outT = outDir.y / outDir.x; 62 | } 63 | 64 | // update 65 | Keyframe key = new Keyframe(t, v, inT, outT); 66 | UpdateKey(i, key); 67 | 68 | // handleMode 69 | if( kp.handleMode == HANDLE_MODE.Auto ){ 70 | curve.SmoothTangents(i, 1.0f); 71 | Keyframe indexKey = curve.keys[i]; 72 | kp.SetInTangent(indexKey.inTangent); 73 | kp.SetOutTangent(indexKey.outTangent); 74 | } 75 | } 76 | 77 | void UpdateKey(int index, Keyframe key) 78 | { 79 | curve.MoveKey(index, key); 80 | } 81 | 82 | 83 | public GizmoDrawAnimCurve gizmoDrawAnimCurve; 84 | 85 | void OnDrawGizmos() 86 | { 87 | if(gizmoDrawAnimCurve != null){ 88 | gizmoDrawAnimCurve.DrawGizmos(curve); 89 | } 90 | } 91 | 92 | 93 | public void RemoveKeyAt(int index) 94 | { 95 | keyFramePoints.RemoveAt(index); 96 | curve.RemoveKey(index); 97 | Debug.Log(curve.keys.Length); 98 | } 99 | public void AddKeyAt() 100 | { 101 | KeyFramePoint kf = addKeyFramePoint; 102 | 103 | int i = curve.AddKey( kf.GetKeyframe() ); 104 | keyFramePoints.Insert(i, kf); 105 | Debug.Log(i + " / "+curve.keys.Length); 106 | } 107 | 108 | void OnGUI() 109 | { 110 | GUILayout.BeginArea(new Rect(10,10,200,200)); 111 | if(GUILayout.Button("RemoveAt 1")){ 112 | RemoveKeyAt(1); 113 | } 114 | if(GUILayout.Button("AddKeyAt")){ 115 | AddKeyAt(); 116 | } 117 | GUILayout.EndArea(); 118 | } 119 | } 120 | 121 | -------------------------------------------------------------------------------- /Assets/AnimationCurveToolMod.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b4d0cc6fce1648c69dc793e850c63b3 3 | timeCreated: 1439887562 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Bezier.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/Assets/Bezier.unity -------------------------------------------------------------------------------- /Assets/Bezier.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ff2f752013e24688adaac132a61d764 3 | timeCreated: 1439804467 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/BezierCurve.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public class BezierCurve : MonoBehaviour { 6 | 7 | [System.Serializable] 8 | public class BezierPoint{ 9 | public Vector3 position; 10 | public Vector3 handle1; 11 | public Vector3 handle2; 12 | } 13 | 14 | public LTBezierPath path; 15 | public List points; 16 | 17 | // Use this for initialization 18 | void Start () { 19 | 20 | } 21 | 22 | // Update is called once per frame 23 | void Update () { 24 | 25 | } 26 | 27 | public int split = 30; 28 | public Color drawColor = Color.red; 29 | 30 | public float x = 0; 31 | 32 | void OnDrawGizmos () { 33 | 34 | List nodes = new List(); 35 | for(int i = 0; i < points.Count-1; i++){ 36 | BezierPoint start = points[i]; 37 | BezierPoint end = points[i+1]; 38 | nodes.Add(start.position); 39 | nodes.Add(end.handle1); 40 | nodes.Add(start.handle2); 41 | nodes.Add(end.position); 42 | } 43 | path = new LTBezierPath(nodes.ToArray()); 44 | 45 | float delta = 1.0f / split; 46 | for(int i = 0; i < split-1; i++){ 47 | float t0 = delta * i; 48 | float t1 = delta * (i+1); 49 | Vector3 pos0 = path.point(t0); 50 | Vector3 pos1 = path.point(t1); 51 | 52 | Gizmos.color = (i % 2 == 0) ? drawColor : Color.clear; 53 | Gizmos.DrawLine(pos0, pos1); 54 | } 55 | 56 | float protSize = 0.05f; 57 | for(int i = 0; i < points.Count; i++){ 58 | BezierPoint p = points[i]; 59 | Gizmos.color = drawColor; 60 | Gizmos.DrawWireSphere( p.position, protSize); 61 | Gizmos.color = Color.green; 62 | Gizmos.DrawWireSphere( p.handle1, protSize); 63 | Gizmos.DrawWireSphere( p.handle2, protSize); 64 | } 65 | 66 | // 67 | Vector3 v = GetEvaluate(x); 68 | Gizmos.color = Color.cyan; 69 | Gizmos.DrawWireSphere( v, 0.1f); 70 | } 71 | 72 | public Vector3 GetEvaluate(float x, int split = 100) 73 | { 74 | x = Mathf.Clamp01(x); 75 | if(x == 0.0f || x == 1.0f){ 76 | return path.point(x); 77 | } 78 | 79 | Vector3 prot0 = new Vector3(x, 0, 0); 80 | Vector3 prot1 = new Vector3(x, 1, 0); 81 | float delta = 1.0f / split; 82 | for(int i = 0; i < split; i++){ 83 | float t0 = delta * i; 84 | float t1 = delta * (i+1); 85 | Vector3 pos0 = path.point(t0); 86 | Vector3 pos1 = path.point(t1); 87 | 88 | Vector3 crossPt = getClossPoint(prot0, pos0, prot1, pos1); 89 | if(crossPt.x >= pos0.x && crossPt.x <= pos1.x){ 90 | return crossPt; 91 | } 92 | } 93 | Debug.Log("Error"); 94 | return Vector3.zero; 95 | } 96 | 97 | public float length 98 | { 99 | get{ 100 | if(path != null){ 101 | return path.length; 102 | }else{ 103 | return 0; 104 | } 105 | } 106 | } 107 | public Vector3 GetPointAt(float p) 108 | { 109 | if(path != null){ 110 | return path.point(p); 111 | }else{ 112 | return Vector3.zero; 113 | } 114 | } 115 | 116 | // 117 | Vector3 getClossPoint(Vector3 P1, Vector3 P2, Vector3 P3, Vector3 P4){ 118 | float S1 = ((P4.x-P2.x)*(P1.y-P2.y)-(P4.y-P2.y)*(P1.x-P2.x))*0.5f; 119 | float S2 = ((P4.x-P2.x)*(P2.y-P3.y)-(P4.y-P2.y)*(P2.x-P3.x))*0.5f; 120 | Vector3 crossPoint = new Vector3(0,0,0); 121 | crossPoint.x = P1.x + (P3.x-P1.x)*(S1/(S1 + S2)); 122 | crossPoint.y = P1.y + (P3.y-P1.y)*(S1/(S1 + S2)); 123 | 124 | return crossPoint; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Assets/BezierCurve.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 536309c9dbf62417089591c2104bd6bf 3 | timeCreated: 1439804477 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/CurveExtension.cs: -------------------------------------------------------------------------------- 1 | // http://wiki.unity3d.com/index.php/EditorAnimationCurveExtension 2 | using UnityEngine; 3 | using System.Collections; 4 | 5 | namespace CurveExtended{ 6 | 7 | public static class CurveExtension { 8 | 9 | public static void UpdateAllLinearTangents(this AnimationCurve curve){ 10 | for (int i = 0; i < curve.keys.Length; i++) { 11 | UpdateTangentsFromMode(curve, i); 12 | } 13 | } 14 | 15 | // UnityEditor.CurveUtility.cs (c) Unity Technologies 16 | public static void UpdateTangentsFromMode(AnimationCurve curve, int index) 17 | { 18 | if (index < 0 || index >= curve.length) 19 | return; 20 | Keyframe key = curve[index]; 21 | if (KeyframeUtil.GetKeyTangentMode(key, 0) == TangentMode.Linear && index >= 1) 22 | { 23 | key.inTangent = CalculateLinearTangent(curve, index, index - 1); 24 | curve.MoveKey(index, key); 25 | } 26 | if (KeyframeUtil.GetKeyTangentMode(key, 1) == TangentMode.Linear && index + 1 < curve.length) 27 | { 28 | key.outTangent = CalculateLinearTangent(curve, index, index + 1); 29 | curve.MoveKey(index, key); 30 | } 31 | if (KeyframeUtil.GetKeyTangentMode(key, 0) != TangentMode.Smooth && KeyframeUtil.GetKeyTangentMode(key, 1) != TangentMode.Smooth) 32 | return; 33 | curve.SmoothTangents(index, 0.0f); 34 | } 35 | 36 | // UnityEditor.CurveUtility.cs (c) Unity Technologies 37 | private static float CalculateLinearTangent(AnimationCurve curve, int index, int toIndex) 38 | { 39 | return (float) (((double) curve[index].value - (double) curve[toIndex].value) / ((double) curve[index].time - (double) curve[toIndex].time)); 40 | } 41 | 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/CurveExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfc64d25335d342eaa197ffbda09871c 3 | timeCreated: 1439801044 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/DragPoint.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class DragPoint : MonoBehaviour { 5 | 6 | // Use this for initialization 7 | void Start () { 8 | 9 | } 10 | 11 | // Update is called once per frame 12 | void Update () { 13 | 14 | } 15 | 16 | void OnMouseDrag() 17 | { 18 | float z = Camera.main.transform.position.z - this.transform.position.z; 19 | Vector3 screenPos = Input.mousePosition; 20 | screenPos.z = Mathf.Abs(z); 21 | Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); 22 | this.transform.position = worldPos; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/DragPoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3aefba93bc6b74a3f8221c1565817a4d 3 | timeCreated: 1446549007 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GizmoDrawAnimCurve.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class GizmoDrawAnimCurve : MonoBehaviour { 5 | 6 | private AnimationCurve curve; 7 | public float split = 100; 8 | 9 | public Color lineColor = Color.red; 10 | public Color pointColor = Color.yellow; 11 | public Color tangentColor = Color.cyan; 12 | 13 | 14 | bool CheckKeyTime(float t0, float t1, out float t, out float v, out Keyframe? out_key) 15 | { 16 | Keyframe[] keys = curve.keys; 17 | for(int i = 0; i < keys.Length; i++){ 18 | Keyframe key = keys[i]; 19 | float keyTime = key.time; 20 | if(keyTime >= t0 && keyTime <= t1){ 21 | t = key.time; 22 | v = key.value; 23 | out_key = key; 24 | return true; 25 | } 26 | } 27 | t = -1; 28 | v = -1; 29 | out_key = null; 30 | return false; 31 | } 32 | 33 | public void DrawGizmos(AnimationCurve curve_) 34 | { 35 | this.curve = curve_; 36 | 37 | Gizmos.color = Color.red; 38 | 39 | // drawLne 40 | 41 | float endTime = curve.keys[curve.keys.Length-1].time; 42 | float delta = (1.0f / split) * endTime; 43 | for(int i = 0; i < split; i++){ 44 | float t0 = delta * i; 45 | float v0 = curve.Evaluate(t0); 46 | 47 | float t1 = delta * (i+1); 48 | float v1 = curve.Evaluate(t1); 49 | 50 | Gizmos.color = (i % 2 == 0) ? lineColor : Color.white; 51 | 52 | float t = 0.0f; 53 | float v = 0.0f; 54 | Keyframe? out_key = null; 55 | if(CheckKeyTime(t0, t1, out t, out v, out out_key)){ 56 | if( IsConstainDraw((Keyframe)out_key) ){ 57 | Gizmos.DrawLine(new Vector3(t0, v0, 0), new Vector3(t, v0, 0)); 58 | t0 = t1 = t; 59 | Gizmos.DrawLine(new Vector3(t0, v0, 0), new Vector3(t1, v1, 0)); 60 | }else{ 61 | Gizmos.DrawLine(new Vector3(t0, v0, 0), new Vector3(t, v, 0)); 62 | Gizmos.DrawLine(new Vector3(t, v, 0), new Vector3(t1, v1, 0)); 63 | } 64 | }else{ 65 | Gizmos.DrawLine(new Vector3(t0, v0, 0), new Vector3(t1, v1, 0)); 66 | } 67 | 68 | // Gizmos.DrawLine(new Vector3(t0, v0, 0), new Vector3(t1, v1, 0)); 69 | } 70 | 71 | // protPoint 72 | Gizmos.color = pointColor; 73 | 74 | Keyframe[] keys = curve.keys; 75 | for(int i = 0; i < keys.Length; i++){ 76 | Keyframe key = keys[i]; 77 | Vector3 pos = new Vector3(key.time, key.value, 0); 78 | Gizmos.DrawWireSphere(pos, 0.05f); 79 | } 80 | // Debug.Log(keys[1].inTangent + " / "+keys[1].outTangent + " / "+keys[1].tangentMode); 81 | 82 | // tangent 83 | Gizmos.color = tangentColor; 84 | 85 | for(int i = 0; i < keys.Length; i++){ 86 | Keyframe key = keys[i]; 87 | Vector3 pos = new Vector3(key.time, key.value, 0); 88 | 89 | float inTan = Mathf.Atan( key.inTangent ); 90 | Vector3 pos_inTangent = pos - new Vector3(Mathf.Cos(inTan), Mathf.Sin(inTan), 0); 91 | 92 | float outTan = Mathf.Atan( key.outTangent ); 93 | Vector3 pos_outTangent = pos + new Vector3(Mathf.Cos(outTan), Mathf.Sin(outTan), 0); 94 | 95 | Gizmos.DrawLine(pos, pos_inTangent); 96 | Gizmos.DrawLine(pos, pos_outTangent); 97 | } 98 | } 99 | 100 | bool IsConstainDraw(Keyframe key) 101 | { 102 | bool isConstain = IsConstain(key); 103 | if(!isConstain){ 104 | int keyIndex = System.Array.IndexOf(curve.keys, key); 105 | 106 | // check preKey 107 | int preKeyIndex = keyIndex - 1; 108 | preKeyIndex = Mathf.Clamp(preKeyIndex, 0, curve.keys.Length-1); 109 | Keyframe preKey = curve.keys[preKeyIndex]; 110 | isConstain = IsConstain(preKey); 111 | } 112 | return isConstain; 113 | } 114 | bool IsConstain(Keyframe key) 115 | { 116 | return (key.inTangent == Mathf.Infinity || key.outTangent == Mathf.Infinity); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Assets/GizmoDrawAnimCurve.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa843ad411e534beaa6cdb63bd2518cd 3 | timeCreated: 1439891281 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/KeyFramePoint.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public enum TANGENT_MODE 5 | { 6 | Free, Linear, Constant 7 | } 8 | public enum HANDLE_MODE 9 | { 10 | Auto, FreeSmooth, Flat, Broken 11 | } 12 | 13 | //[ExecuteInEditMode] 14 | public class KeyFramePoint : MonoBehaviour { 15 | 16 | public Transform inTrans; 17 | public Transform outTrans; 18 | 19 | public float inTangent; 20 | public float outTangent; 21 | 22 | public TANGENT_MODE inTangentMode = TANGENT_MODE.Free; 23 | public TANGENT_MODE outTangentMode = TANGENT_MODE.Free; 24 | 25 | public HANDLE_MODE handleMode = HANDLE_MODE.Broken; 26 | 27 | private float handleDist = 1.0f; 28 | 29 | // Use this for initialization 30 | void Awake () { 31 | Update(); 32 | } 33 | 34 | // Update is called once per frame 35 | void Update () { 36 | if(handleMode == HANDLE_MODE.Flat){ 37 | Vector3 basePos = this.transform.position; 38 | inTrans.position = new Vector3(basePos.x-1, basePos.y, 0); 39 | outTrans.position = new Vector3(basePos.x+1, basePos.y, 0); 40 | }else if(handleMode == HANDLE_MODE.FreeSmooth){ 41 | inTrans.localPosition = -outTrans.localPosition; 42 | } 43 | 44 | Vector3 inNormalVec = inTrans.localPosition; 45 | Vector3 outNormalVec = outTrans.localPosition; 46 | inNormalVec.Normalize(); 47 | outNormalVec.Normalize(); 48 | 49 | if(inNormalVec.x < 0 && inTangentMode != TANGENT_MODE.Constant){ 50 | inTangent = inNormalVec.y / inNormalVec.x; 51 | }else{ 52 | inTangent = Mathf.Infinity; 53 | } 54 | if(outNormalVec.x > 0 && outTangentMode != TANGENT_MODE.Constant){ 55 | outTangent = outNormalVec.y / outNormalVec.x; 56 | }else{ 57 | outTangent = Mathf.Infinity; 58 | } 59 | 60 | // control position 61 | if(inNormalVec.x > 0){ 62 | Vector3 tIPos = inTrans.localPosition; 63 | tIPos.x = 0; 64 | inTrans.localPosition = tIPos; 65 | } 66 | if(outNormalVec.x < 0){ 67 | Vector3 tOPos = outTrans.localPosition; 68 | tOPos.x = 0; 69 | outTrans.localPosition = tOPos; 70 | } 71 | 72 | inTrans.localPosition = inTrans.localPosition.normalized * handleDist; 73 | outTrans.localPosition = outTrans.localPosition.normalized * handleDist; 74 | 75 | // handle visible 76 | if(inTangentMode == TANGENT_MODE.Constant || handleMode == HANDLE_MODE.Auto){ 77 | inTrans.gameObject.SetActive(false); 78 | }else{ 79 | inTrans.gameObject.SetActive(true); 80 | } 81 | if(outTangentMode == TANGENT_MODE.Constant || handleMode == HANDLE_MODE.Auto){ 82 | outTrans.gameObject.SetActive(false); 83 | }else{ 84 | outTrans.gameObject.SetActive(true); 85 | } 86 | } 87 | 88 | public float time 89 | { 90 | get{ 91 | return this.transform.position.x; 92 | } 93 | } 94 | public float v 95 | { 96 | get{ 97 | return this.transform.position.y; 98 | } 99 | } 100 | 101 | public Vector3 position 102 | { 103 | get{ 104 | return this.transform.position; 105 | } 106 | } 107 | 108 | public void SetInTangent(float tangent) 109 | { 110 | float t = Mathf.Atan( tangent ); 111 | inTrans.localPosition = -new Vector3(Mathf.Cos(t), Mathf.Sin(t), 0) * handleDist; 112 | } 113 | public void SetOutTangent(float tangent) 114 | { 115 | float t = Mathf.Atan( tangent ); 116 | outTrans.localPosition = new Vector3(Mathf.Cos(t), Mathf.Sin(t), 0) * handleDist; 117 | } 118 | 119 | public Keyframe GetKeyframe() 120 | { 121 | Keyframe kf = new Keyframe(time, v, inTangent, outTangent); 122 | return kf; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Assets/KeyFramePoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e14fc9ae1e034569a0f7132a3794811 3 | timeCreated: 1439887630 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/KeyFramePoint.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/Assets/KeyFramePoint.prefab -------------------------------------------------------------------------------- /Assets/KeyFramePoint.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8174b388fc6145cbbea9312f3b208a8 3 | timeCreated: 1439887737 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/KeyframeUtil.cs: -------------------------------------------------------------------------------- 1 | // http://wiki.unity3d.com/index.php/EditorAnimationCurveExtension 2 | using UnityEngine; 3 | using System.Collections; 4 | using System.Reflection; 5 | using System; 6 | 7 | namespace CurveExtended{ 8 | public enum TangentMode 9 | { 10 | Editable = 0, // Free 11 | Smooth = 1, // Auto 12 | Linear = 2, // Linear 13 | Stepped = Linear | Smooth // Constant 14 | } 15 | 16 | public enum TangentDirection 17 | { 18 | Left, 19 | Right 20 | } 21 | 22 | 23 | public class KeyframeUtil { 24 | 25 | public static Keyframe GetNew( float time, float value, TangentMode leftAndRight){ 26 | return GetNew(time,value, leftAndRight,leftAndRight); 27 | } 28 | 29 | public static Keyframe GetNew(float time, float value, TangentMode left, TangentMode right){ 30 | object boxed = new Keyframe(time,value); // cant use struct in reflection 31 | 32 | SetKeyBroken(boxed, true); 33 | SetKeyTangentMode(boxed, 0, left); 34 | SetKeyTangentMode(boxed, 1, right); 35 | 36 | Keyframe keyframe = (Keyframe)boxed; 37 | if (left == TangentMode.Stepped ) 38 | keyframe.inTangent = float.PositiveInfinity; 39 | if (right == TangentMode.Stepped ) 40 | keyframe.outTangent = float.PositiveInfinity; 41 | 42 | return keyframe; 43 | } 44 | 45 | 46 | // UnityEditor.CurveUtility.cs (c) Unity Technologies 47 | public static void SetKeyTangentMode(object keyframe, int leftRight, TangentMode mode) 48 | { 49 | 50 | Type t = typeof( UnityEngine.Keyframe ); 51 | FieldInfo field = t.GetField( "m_TangentMode", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance ); 52 | int tangentMode = (int)field.GetValue(keyframe); 53 | 54 | if (leftRight == 0) 55 | { 56 | tangentMode &= -7; 57 | tangentMode |= (int) mode << 1; 58 | } 59 | else 60 | { 61 | tangentMode &= -25; 62 | tangentMode |= (int) mode << 3; 63 | } 64 | 65 | field.SetValue(keyframe, tangentMode); 66 | if (GetKeyTangentMode(tangentMode, leftRight) == mode) 67 | return; 68 | Debug.Log("bug"); 69 | } 70 | 71 | // UnityEditor.CurveUtility.cs (c) Unity Technologies 72 | public static TangentMode GetKeyTangentMode(int tangentMode, int leftRight) 73 | { 74 | if (leftRight == 0) 75 | return (TangentMode) ((tangentMode & 6) >> 1); 76 | else 77 | return (TangentMode) ((tangentMode & 24) >> 3); 78 | } 79 | 80 | // UnityEditor.CurveUtility.cs (c) Unity Technologies 81 | public static TangentMode GetKeyTangentMode(Keyframe keyframe, int leftRight) 82 | { 83 | Type t = typeof( UnityEngine.Keyframe ); 84 | FieldInfo field = t.GetField( "m_TangentMode", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance ); 85 | int tangentMode = (int)field.GetValue(keyframe); 86 | if (leftRight == 0) 87 | return (TangentMode) ((tangentMode & 6) >> 1); 88 | else 89 | return (TangentMode) ((tangentMode & 24) >> 3); 90 | } 91 | 92 | 93 | // UnityEditor.CurveUtility.cs (c) Unity Technologies 94 | public static void SetKeyBroken(object keyframe, bool broken) 95 | { 96 | Type t = typeof( UnityEngine.Keyframe ); 97 | FieldInfo field = t.GetField( "m_TangentMode", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance ); 98 | int tangentMode = (int)field.GetValue(keyframe); 99 | 100 | if (broken) 101 | tangentMode |= 1; 102 | else 103 | tangentMode &= -2; 104 | field.SetValue(keyframe, tangentMode); 105 | } 106 | 107 | } 108 | } -------------------------------------------------------------------------------- /Assets/KeyframeUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80870d39e7e394373b4e3ba214373a16 3 | timeCreated: 1439798379 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64d3b2adadb6d46369ef77e8faab0a63 3 | folderAsset: yes 4 | timeCreated: 1439804442 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Plugins/LeanTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1cfe8e120dbc9496781ae509415dbfcb 3 | timeCreated: 1439804454 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/pivotMat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/Assets/pivotMat.mat -------------------------------------------------------------------------------- /Assets/pivotMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2d41208d788d4477a09fc31950b8142 3 | timeCreated: 1439890323 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.2.2p3 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAnalyticsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inoook/AnimationCurveEditor/d7d3895d8b41ac0e85bbe2d20e0a2fe2e09be81d/ProjectSettings/UnityAnalyticsManager.asset --------------------------------------------------------------------------------