22/06/21 14:44:08.12 ONM36TGF.net
作成した .anim ファイルの設定を Editor スクリプトから変えたいのですが方法がわからずご存じの方いたら教えてもらえないでしょうか
FBX に埋め込まれた .anim の設定を変更するなら ModelImporter / ModelImporterClipAnimation 経由でできるのですが、
抽出済み、または Unity 内で作成した .anim に ModelImporterClipAnimation 型を適用する方法がわかりません
URLリンク(docs.unity3d.com)
```csharp
[SerializeField] public AnimationClip animationClip = null;
var path = AssetDatabase.GetAssetPath(animationClip);
// 1. ModelImporter にキャスト → InvalidCastException: Specified cast is not valid.
var importer = (ModelImporter) AssetImporter.GetAtPath(path);
foreach (var clip in importer.clipAnimations) {
clip.heightOffset = -0.1f;
}
// 2. ModelImporterClipAnimation にキャスト → InvalidCastException: Specified cast is not valid.
var importerClipAnimation = (ModelImporterClipAnimation) AssetImporter.GetAtPath(path);
importerClipAnimation.heightOffset = -0.1f;
AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
```
下記画像のように .anim の Root Transform Position (Y) Offset を -0.1 にしたいです
URLリンク(i.imgur.com)