Example #1
0
        private void DrawKeyFrameMarkers()
        {
            int i = 0;

            foreach (KeyFrame keyFrame in this.cameraController.keyFrames)
            {
                float t         = (keyFrame.time - this.recorder.startTime) / (this.recorder.endTime - this.recorder.startTime);
                Color textColor = (keyFrame is FreeCameraKeyFrame) ? Color.blue : ((keyFrame is OrbitCameraKeyFrame) ? Color.red : Color.green);
                ReplaySkin.DefaultSkin.markerStyle.normal.textColor = textColor;
                Rect markerRect = ReplaySkin.DefaultSkin.MarkerRectForNormT(t);
                int  index      = i;
                GUIHelper.DraggableArea(
                    "keyframe" + keyFrame.GetHashCode(),
                    markerRect,
                    delegate(out bool beginDrag) {   //GUI Draw
                    GUILayout.BeginVertical();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label("|", ReplaySkin.DefaultSkin.markerStyle, GUILayout.ExpandHeight(true));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    beginDrag = GUILayout.RepeatButton("O", ReplaySkin.DefaultSkin.markerStyle);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                },
                    () => SetPlaybackTime(keyFrame.time),
                    delegate(ref Rect r) {   //OnDragUpdate
                    float xmin = ReplaySkin.DefaultSkin.sliderRect.xMin + (float)ReplaySkin.DefaultSkin.sliderPadding / 2f;
                    float xmax = ReplaySkin.DefaultSkin.sliderRect.xMax - (float)ReplaySkin.DefaultSkin.sliderPadding / 2f;
                    r.center   = new Vector2(Mathf.Clamp(r.center.x, xmin, xmax), markerRect.center.y);
                    float time = this.recorder.startTime + ReplaySkin.DefaultSkin.NormTForMarkerRect(r) * (this.recorder.endTime - this.recorder.startTime);
                    keyFrame.ApplyTo(cameraController.camera);
                    SetPlaybackTime(time);
                },
                    delegate(Rect r) {   //OnDrop
                    float time = this.recorder.startTime + ReplaySkin.DefaultSkin.NormTForMarkerRect(r) * (this.recorder.endTime - this.recorder.startTime);
                    keyFrame.Update(cameraController.camera.transform, time);
                    cameraController.cameraCurve.DeleteCurveKeys(index);
                    keyFrame.AddKeyframes(cameraController.cameraCurve);
                },
                    this,
                    true);
                i++;
            }
        }