Beispiel #1
0
 void GenAnim2()
 {
     AnimationCurve[] eachCurves = new AnimationCurve[6];
     for (int u = 0; u < eachCurves.Length; u++)
     {
         eachCurves[u] = new AnimationCurve();
     }
     for (int i = 0; i < effectShakeCameraInfo.timeLine.length; i++)
     {
         Keyframe frame = effectShakeCameraInfo.timeLine[i];
         CameraShakerEditor.KeyExInfo keyExinfo;
         if (i < effectShakeCameraInfo.keyExInfos.Count)
         {
             keyExinfo = effectShakeCameraInfo.keyExInfos[i];
             var calCurves = CameraShakerUtil.CreateShakeCurve(keyExinfo.shakePosition, keyExinfo.shakeAngle, keyExinfo.cycleTime, keyExinfo.cycleCount, keyExinfo.fixShake);
             for (int j = 0; j < 6; j++)
             {
                 float startTime = keyExinfo.keyTime;
                 foreach (var calframe in calCurves[j].keys)
                 {
                     Keyframe newFrame = new Keyframe(startTime + calframe.time, calframe.value);
                     eachCurves[j].AddKey(newFrame);
                 }
             }
         }
     }
     for (int k = 0; k < eachCurves.Length; k++)
     {
         effectShakeCameraInfo.GetType().GetField(s_propertys[k]).SetValue(effectShakeCameraInfo, eachCurves[k]);
     }
 }
Beispiel #2
0
        void GenAnim1()
        {
            AnimationCurve[] eachCurves = new AnimationCurve[6];
            for (int u = 0; u < eachCurves.Length; u++)
            {
                if (effectShakeCameraInfo.modeRidio == 0)
                {
                    eachCurves[u] = (u < 3) ? AnimationCurve.Linear(0, 0, 0, 0) : new AnimationCurve();
                }
                else if (effectShakeCameraInfo.modeRidio == 1)
                {
                    eachCurves[u] = (u < 3) ? new AnimationCurve() : AnimationCurve.Linear(0, 0, 0, 0);
                }
            }

            for (int i = 0; i < effectShakeCameraInfo.eachTimeLines.Length; i++)
            {
                var timeLine = effectShakeCameraInfo.eachTimeLines[i];
                for (int j = 0; j < timeLine.keys.Length - 1; j++)
                {
                    var   timeLineFrame = timeLine.keys[j];
                    float starTime      = timeLineFrame.time;
                    float motionAmpl    = timeLineFrame.value * s_scaleRate;
                    float cycTime       = effectShakeCameraInfo.cycTime;
                    if (j + 1 < timeLine.keys.Length)
                    {
                        float totalTime = timeLine.keys[j + 1].time - starTime;
                        if (effectShakeCameraInfo.cycTime * effectShakeCameraInfo.cycCount > totalTime)
                        {
                            cycTime = totalTime / effectShakeCameraInfo.cycCount;
                        }
                    }
                    AnimationCurve calCurve = CameraShakerUtil.CreateSimpleHarmonicCurve(motionAmpl, cycTime, effectShakeCameraInfo.cycCount, effectShakeCameraInfo.isFixTime);

                    foreach (var frame in calCurve.keys)
                    {
                        Keyframe newFrame = new Keyframe(starTime + frame.time, frame.value);
                        eachCurves[s_simpleIndex[i]].AddKey(newFrame);
                    }
                }
            }
            for (int k = 0; k < eachCurves.Length; k++)
            {
                effectShakeCameraInfo.GetType().GetField(s_propertys[k]).SetValue(effectShakeCameraInfo, eachCurves[k]);
            }
        }
        void OnGUI()
        {
            GUILayout.BeginVertical();

            EditorGUILayout.CurveField("曲线", s_curCurve);
            maxRange = EditorGUILayout.FloatField("最大震幅", maxRange);

            cycleTime  = EditorGUILayout.FloatField("周期", cycleTime);
            cycleCount = EditorGUILayout.IntField("次数", cycleCount);
            fixShake   = EditorGUILayout.Toggle("振幅不减", fixShake);

            if (GUILayout.Button("产生"))
            {
                Vector3 positionShake = Vector3.zero;
                Vector3 angleShake    = Vector3.zero;
                var     curve         = CameraShakerUtil.CreateSimpleHarmonicCurve(maxRange, cycleTime, cycleCount, fixShake);
                s_curCurve = curve;
                s_curCallback(s_curCurve);
            }

            GUILayout.EndVertical();
        }