示例#1
0
    // question - should this be invoked after the keyframe has been added to the curve? - answer, YES, after anim Curve has completed curve data update for all 3 positions

    public void AddKeyFrameUI(float time, out VideoKeyFrame newK)
    {
        int keyframeIndex;

        if (isVideoKeyFrameHere(time, out keyframeIndex))
        {
            Destroy(videoKeyFrames[keyframeIndex].gameObject);
        }
        GameObject keyframeObj = Instantiate(timeline.keyframePrefab.gameObject, transform);

        newK = keyframeObj.GetComponent <VideoKeyFrame>();
        newK.keyframeTime = time;
        videoKeyFrames.Add(newK);

        if (!isTimeWithinTimelineClampedTime(newK.keyframeTime))
        {
            newK.gameObject.SetActive(false);
        }
        else
        {
            UpdateKeyframeUI();
        }


        sortVideoKeyframesByTime();     // ensure the correct indices in the track for proper retrival of keyframes

        newK.animTrack = this;

        // get keyframe indices and insert them onto videokeyframe
        int keyframePosIndexX = animCurve.getKeyframeIndicesFromCurve(timeline.timelineTicker.currentTime, AnimationCurveToUpdate.x);
        int keyframePosIndexY = animCurve.getKeyframeIndicesFromCurve(timeline.timelineTicker.currentTime, AnimationCurveToUpdate.y);
        int keyframePosIndexZ = animCurve.getKeyframeIndicesFromCurve(timeline.timelineTicker.currentTime, AnimationCurveToUpdate.z);

        Debug.Log("keyframeIndexX " + keyframePosIndexX + " keyframePosIndexY " + keyframePosIndexY + " keyframeIndexZ " + keyframePosIndexZ);

        newK.keyframeXindex = keyframePosIndexX;
        newK.keyframeYindex = keyframePosIndexY;
        newK.keyframeZindex = keyframePosIndexZ;
    }