Esempio n. 1
0
    // these are non timeline methods // they come from the UI menu next to gimbals
    public void addKeyFrameToCurve(Keyframe keyframe, AnimationCurveToUpdate curve)
    {
        int keyFrameIndex;

        switch (curve)
        {
        case AnimationCurveToUpdate.x:
            keyFrameIndex = curveX.AddKey(keyframe);
            clip.SetCurve("", typeof(Transform), "localPosition.x", curveX);

            if (animTrack.onKeyframeAdded != null)
            {
                animTrack.onKeyframeAdded(keyFrameIndex, keyframe.time, curve);
            }

            break;

        case AnimationCurveToUpdate.y:
            keyFrameIndex = curveY.AddKey(keyframe);
            clip.SetCurve("", typeof(Transform), "localPosition.y", curveY);

            if (animTrack.onKeyframeAdded != null)
            {
                animTrack.onKeyframeAdded(keyFrameIndex, keyframe.time, curve);
            }
            break;

        case AnimationCurveToUpdate.z:
            keyFrameIndex = curveZ.AddKey(keyframe);
            clip.SetCurve("", typeof(Transform), "localPosition.z", curveZ);

            if (animTrack.onKeyframeAdded != null)
            {
                animTrack.onKeyframeAdded(keyFrameIndex, keyframe.time, curve);
            }
            break;

        case AnimationCurveToUpdate.rotationX:
            keyFrameIndex = rotationXcurve.AddKey(keyframe);
            clip.SetCurve("", typeof(Transform), "localRotation.x", rotationXcurve);

            if (animTrack.onKeyframeAdded != null)
            {
                animTrack.onKeyframeAdded(keyFrameIndex, keyframe.time, curve);
            }
            break;

        case AnimationCurveToUpdate.rotationY:
            keyFrameIndex = rotationYcurve.AddKey(keyframe);
            clip.SetCurve("", typeof(Transform), "localRotation.y", rotationYcurve);

            if (animTrack.onKeyframeAdded != null)
            {
                animTrack.onKeyframeAdded(keyFrameIndex, keyframe.time, curve);
            }
            break;

        case AnimationCurveToUpdate.rotationZ:
            keyFrameIndex = rotationZcurve.AddKey(keyframe);
            clip.SetCurve("", typeof(Transform), "localRotation.z", rotationZcurve);

            if (animTrack.onKeyframeAdded != null)
            {
                animTrack.onKeyframeAdded(keyFrameIndex, keyframe.time, curve);
            }
            break;
        }

        // if(animTrack.onKeyFrameAdded != null)
        //    {
        //        animTrack.onKeyFrameAdded(keyframe,curve);
        //    }
    }