private static void DrawSequence(DataCreator creator, AnimationsSequence seq, int index, float rectWidth)
        {
            if (seq.findPoseInClip.Count != seq.clips.Count)
            {
                for (int i = 0; i < seq.clips.Count; i++)
                {
                    seq.findPoseInClip.Add(true);
                }
            }
            GUILayoutElements.DrawHeader(
                seq.name,
                GUIResources.GetLightHeaderStyle_MD()
                );

            GUILayout.Space(5);

            seq.name = EditorGUILayout.TextField(
                new GUIContent("Animation sequence name"),
                seq.name
                );

            //seq.loop = EditorGUILayout.Toggle(
            //    new GUIContent("Loop"),
            //    seq.loop
            //    );

            seq.findInYourself  = EditorGUILayout.Toggle(new GUIContent("Find in yourself"), seq.findInYourself);
            seq.blendToYourself = EditorGUILayout.Toggle(new GUIContent("Blend to yourself"), seq.blendToYourself);

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add clip"))
            {
                seq.AddClip(null);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            float floatWidth  = 60f;
            float buttonWidth = 25f;
            float findPose    = 60f;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Animation");
            GUILayout.Label("Find pose", GUILayout.Width(findPose));
            GUILayout.Label("Start", GUILayout.Width(floatWidth));
            GUILayout.Label("End", GUILayout.Width(floatWidth));
            GUILayout.Label("Blend", GUILayout.Width(floatWidth));
            GUILayout.Space(buttonWidth);
            GUILayout.EndHorizontal();
            for (int i = 0; i < seq.clips.Count; i++)
            {
                GUILayout.BeginHorizontal();
                //GUILayout.Label(string.Format("{0}.", i + 1));
                seq.clips[i] = (AnimationClip)EditorGUILayout.ObjectField(
                    seq.clips[i],
                    typeof(AnimationClip),
                    true
                    );

                seq.findPoseInClip[i] = EditorGUILayout.Toggle(seq.findPoseInClip[i], GUILayout.Width(findPose));

                float x = seq.neededInfo[i].x;
                float y = seq.neededInfo[i].y;
                float z = seq.neededInfo[i].z;

                //GUILayout.Label("Start time");
                x = EditorGUILayout.FloatField(x, GUILayout.Width(floatWidth));
                //GUILayout.Label("Blend start time");
                y = EditorGUILayout.FloatField(y, GUILayout.Width(floatWidth));
                //GUILayout.Label("Blend time");
                z = EditorGUILayout.FloatField(z, GUILayout.Width(floatWidth));

                seq.neededInfo[i] = new Vector3(x, y, z);

                if (GUILayout.Button("X", GUILayout.Width(buttonWidth)))
                {
                    seq.RemoveAnimationsAt(i);
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            //deltaTimeCaculation = Time.realtimeSinceStartup;

            seq.CalculateLength();
            GUILayout.Label(string.Format("Sequence length: \t {0}", seq.length));


            GUILayout.Space(10);
        }
        public static MotionMatchingData CalculateAnimationSequenceData(
            string name,
            AnimationsSequence seq,
            GameObject go,
            PreparingDataPlayableGraph graph,
            List <Transform> bonesMask,
            List <Vector2> bonesWeights,
            int sampling,
            bool loop,
            Transform root,
            List <float> trajectoryStepTimes,
            bool blendToYourself,
            bool findInYourself
            )
        {
            if (!graph.IsValid())
            {
                graph.Initialize(go);
            }

            go.transform.position = Vector3.zero;
            go.transform.rotation = Quaternion.identity;

            seq.CalculateLength();

            #region need floats
            float frameTime      = 1f / (float)sampling;
            int   numberOfFrames = Mathf.FloorToInt(seq.length / frameTime) + 1;
            #endregion

            MotionMatchingData data = new MotionMatchingData(
                seq.clips.ToArray(),
                seq.neededInfo.ToArray(),
                sampling,
                name,
                loop,
                seq.length,
                findInYourself,
                blendToYourself,
                AnimationDataType.AnimationSequence
                );

            FrameData  frameBuffer;
            BoneData   boneBuffer;
            PoseData   poseBuffor;
            Trajectory trajectoryBuffor;

            NeedValueToCalculateData[] previuData = new NeedValueToCalculateData[bonesMask.Count];
            NeedValueToCalculateData[] nextData   = new NeedValueToCalculateData[bonesMask.Count];

            int seqDeltaSampling = 3;
            //seq.CreatePlayableGraph(playableGraph, go);
            //seq.Update(-frameTime, playableGraph, seqDeltaSampling);

            seq.CreateAnimationsInTime(0f, graph);
            graph.Evaluate(frameTime);
            seq.Update(graph, frameTime);

            int frameIndex = 0;

            for (; frameIndex < numberOfFrames; frameIndex++)
            {
                for (int i = 0; i < bonesMask.Count; i++)
                {
                    previuData[i] = GetValuesFromTransform(bonesMask[i], root);
                }

                graph.Evaluate(frameTime);
                seq.Update(graph, frameTime);
                //Debug.Log((float)animator.GetMixerInputTime(0) - clip.length);

                for (int i = 0; i < bonesMask.Count; i++)
                {
                    nextData[i] = GetValuesFromTransform(bonesMask[i], root);
                }

                poseBuffor = new PoseData(bonesMask.Count);
                for (int i = 0; i < bonesMask.Count; i++)
                {
                    float2     boneWeight    = bonesWeights[i];
                    float3     velocity      = BoneData.CalculateVelocity(previuData[i].position, nextData[i].position, frameTime);
                    float3     localPosition = previuData[i].position;
                    quaternion orientation   = previuData[i].rotation;
                    boneBuffer = new BoneData(localPosition, velocity);
                    poseBuffor.SetBone(boneBuffer, i);
                }

                trajectoryBuffor = new Trajectory(trajectoryStepTimes.Count);

                frameBuffer = new FrameData(
                    frameIndex,
                    frameIndex * frameTime,
                    trajectoryBuffor,
                    poseBuffor,
                    new FrameSections(true)
                    );
                data.AddFrame(frameBuffer);
            }


            float   clipGlobalStart;
            Vector2 clipStartAndStop;
            float   recordingClipTime;

            if (trajectoryStepTimes[0] < 0)
            {
                clipGlobalStart = trajectoryStepTimes[0];

                clipStartAndStop = new Vector2(-clipGlobalStart, -clipGlobalStart + seq.length);
            }
            else
            {
                clipGlobalStart  = 0;
                clipStartAndStop = new Vector2(0, seq.length);
            }

            if (trajectoryStepTimes[trajectoryStepTimes.Count - 1] > 0)
            {
                recordingClipTime = clipStartAndStop.y + trajectoryStepTimes[trajectoryStepTimes.Count - 1] + 0.1f;
            }
            else
            {
                recordingClipTime = clipStartAndStop.y + 0.1f;
            }

            int   samplesPerSecond = 100;
            float deltaTime        = 1f / (float)samplesPerSecond;
            int   dataCount        = Mathf.CeilToInt(recordingClipTime / deltaTime);

            NeedValueToCalculateData[] recordData = new NeedValueToCalculateData[dataCount];

            go.transform.position = Vector3.zero;
            go.transform.rotation = Quaternion.identity;

            //seq.Update(clipGlobalStart, playableGraph);

            graph.ClearMainMixerInput();

            seq.CreateAnimationsInTime(clipGlobalStart, graph);

            recordData[0] = new NeedValueToCalculateData(
                go.transform.position,
                go.transform.forward,
                go.transform.rotation
                );

            for (int i = 0; i < dataCount; i++)
            {
                graph.Evaluate(deltaTime);
                seq.Update(graph, deltaTime);
                recordData[i] = new NeedValueToCalculateData(
                    go.transform.position,
                    go.transform.forward,
                    go.transform.rotation
                    );
            }

            //clearing graph from all animations
            graph.ClearMainMixerInput();

            MotionDataCalculator.CalculateTrajectoryPointsFromRecordData(
                data,
                recordData,
                recordingClipTime,
                deltaTime,
                clipStartAndStop,
                trajectoryStepTimes
                );

            data.usedFrameCount = data.numberOfFrames;

            data.trajectoryPointsTimes = new List <float>();

            for (int i = 0; i < trajectoryStepTimes.Count; i++)
            {
                data.trajectoryPointsTimes.Add(trajectoryStepTimes[i]);
            }

            return(data);
        }