Files
kicking-high/proto3/godot/import/import_multi.gd
2020-04-13 12:45:25 +03:00

43 lines
1.4 KiB
GDScript

tool
extends EditorScenePostImport
export var save_path = "res://scenes/characters/animation"
var data = {}
func process_anim(ap):
for e in ap.get_animation_list():
var anim_split = e.replace("-loop", "").split("_")
if anim_split.size() < 2:
continue
var anim_name = anim_split[0]
var anim_index = anim_split[1]
var an = ap.get_animation(e)
ResourceSaver.save(save_path + "/" + e + ".anim", an)
if !data.has(anim_name):
data[anim_name] = {}
data[anim_name][anim_index] = e
func create_states():
for k in data.keys():
for l in data[k].keys():
var st: = AnimationNodeBlendTree.new()
st.resource_name = k + "_" + l
var an = AnimationNodeAnimation.new()
an.animation = data[k][l]
var ts = AnimationNodeTimeScale.new()
st.set_node_position("output", Vector2(600, 60))
st.add_node(k + "_" + l + "_animation", an, Vector2(0, 60))
st.add_node(k + "_" + l + "_timescale", ts, Vector2(300, 60))
st.connect_node(k + "_" + l + "_timescale", 0, k + "_" + l + "_animation")
st.connect_node("output", 0, k + "_" + l + "_timescale")
ResourceSaver.save(save_path + "/blendtree_" + k + "_" + l + ".tres", st)
func post_import(scene):
if scene.get_node("first"):
var ap: AnimationPlayer = scene.get_node("first/AnimationPlayer")
process_anim(ap)
if scene.get_node("second"):
var ap: AnimationPlayer = scene.get_node("second/AnimationPlayer")
process_anim(ap)
create_states()
return scene