Skip to content

Instantly share code, notes, and snippets.

@yamahigashi
Last active December 28, 2015 09:48
Show Gist options
  • Save yamahigashi/7481145 to your computer and use it in GitHub Desktop.
Save yamahigashi/7481145 to your computer and use it in GitHub Desktop.
Unity3d で 自動クリップ作成サンプル
class FbxImporter(AssetPostprocessor):
def OnPostprocessModel(go as GameObject):
im as ModelImporter = assetImporter
ap as string = assetPath
make_clip(im, ap)
def make_clip(importer as ModelImporter, path as string):
AssetDatabase.StartAssetEditing()
log "アニメーション分割開始"
motions as ArrayList = motionSplitInfoFromConfig(path)
mica as (ModelImporterClipAnimation) = array(ModelImporterClipAnimation, motions.Count)
for i as int, entry as ArrayList in enumerate(motions):
clipName = fname + entry[0]
start = entry[1]
try:
end = entry[2]
except ArgumentOutOfRangeException:
end = _getFBXFrame(path)
mica[i] = ModelImporterClipAnimation()
mica[i].takeName = clipName
mica[i].name = clipName
mica[i].firstFrame = start
mica[i].lastFrame = end
importer.clipAnimations = mica
EditorApplication.SaveAssets()
AssetDatabase.StopAssetEditing()
AssetDatabase.Refresh()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment