複製AnimationCurve

yanghui01發表於2024-05-17

public static float TrimFloat(float f)
{
    int i = (int)(f * 1000);
    float result = i / 1000.0f;
    return result;
}

public static AnimationCurve CloneAnimCurve(AnimationCurve srcCurve)
{
    var cloneCurve = new AnimationCurve();
    
    Keyframe[] srcKeyFrames = srcCurve.keys; //所有關鍵幀for (int i = 0; i < srcKeyFrames.Length; ++i)
    {
        var kf = srcKeyFrames[i];
        cloneCurve.AddKey(kf);
    }
    
    return cloneCurve;
}

相關文章