Skip to content

Instantly share code, notes, and snippets.

@fujimisakari
Created March 9, 2014 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujimisakari/9441614 to your computer and use it in GitHub Desktop.
Save fujimisakari/9441614 to your computer and use it in GitHub Desktop.
fbxファイルからAnimationClipを取得する ref: http://qiita.com/fujimisakari/items/dfcc1230cd135cf134a1
public List<AnimationClip> GetAnimationClipInFbx(string iFbxFileName)
{
// 現在のLoad中のAnimationClipをUnloadし、何もLoadしていない状態にする
Resources.FindObjectsOfTypeAll<AnimationClip>().ToList().ForEach(x => Resources.UnloadAsset(x));
// AnimationClipを取り出したいFbxファイルをLoadする
string aFbxFilePath = Application.dataPath + "/Resources/Models/" + iFbxFileName;
aFbxFilePath = aFbxFilePath.Replace(".fbx", "").Replace("\\", "/");
Resources.LoadAll(aFbxFilePath);
// 現在のLoad中のみのAnimationClipを返す
var aAnimationClips = Resources.FindObjectsOfTypeAll<AnimationClip>();
List<AnimationClip> aAnimationClipList = new List<AnimationClip>();
foreach (var aAnimationClip in aAnimationClips)
{
if (Regex.IsMatch(aAnimationClip.name, @"^Take\d*"))
{
aAnimationClipList.Add(aAnimationClip);
}
}
return aAnimationClipList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment