Created
September 4, 2019 05:53
-
-
Save yowasou/9e0fb5e838aa31023fc72a5916699407 to your computer and use it in GitHub Desktop.
Unityでアニメーションをスクリプトから作成
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static AnimationClip CreateAnimationClip(VMDFormat format, int interpolationQuality) | |
{ | |
VMDVRoidConverter converter = new VMDVRoidConverter(); | |
//アニメーションクリップを作成 | |
AnimationClip clip = new AnimationClip(); | |
clip.name = "output_test"; | |
//キーフレーム作成 | |
AnimationCurve retCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)); | |
//カーブ作成 | |
for (int i = 0; i < retCurve.keys.Length; i++) | |
{ | |
AnimationUtility.SetKeyLeftTangentMode(retCurve, i, AnimationUtility.TangentMode.ClampedAuto); | |
AnimationUtility.SetKeyRightTangentMode(retCurve, i, AnimationUtility.TangentMode.ClampedAuto); | |
} | |
//キーフレームを指定したボーンに適用 | |
AnimationUtility.SetEditorCurve(clip, EditorCurveBinding.FloatCurve("Animator", typeof(Transform), "Root T.y"), retCurve); | |
//アニメーションクリップのアセットを作成 | |
AssetDatabase.CreateAsset(clip, "Assets/VRoidAnimation/" + clip.name + ".anim"); | |
return clip; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment