Created
March 9, 2014 01:22
-
-
Save fujimisakari/9441614 to your computer and use it in GitHub Desktop.
fbxファイルからAnimationClipを取得する ref: http://qiita.com/fujimisakari/items/dfcc1230cd135cf134a1
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 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