feature/blend_tree_editor #1
@ -350,6 +350,7 @@ public:
|
||||
void set_animation_player(AnimationPlayer *p_player);
|
||||
bool set_animation(const StringName &p_name);
|
||||
StringName get_animation() const;
|
||||
AnimationPlayer *get_animation_player() const;
|
||||
|
||||
TypedArray<StringName> get_animations_as_typed_array() const;
|
||||
|
||||
|
||||
@ -6,12 +6,13 @@ class_name AnimationGraphEditor
|
||||
@onready var breadcrumb_button_container: HBoxContainer = %BreadcrumbButtons
|
||||
@onready var active_graph_control: Control = %ActiveGraphControl
|
||||
|
||||
var active_animation_graph_node:BLTAnimationGraph = null
|
||||
var animation_graph:BLTAnimationGraph = null
|
||||
var animation_graph_root_node:BLTAnimationNode = null
|
||||
var graph_node_stack:Array[BLTAnimationNode] = []
|
||||
var active_graph_edit:Control = null
|
||||
var active_graph_edit_index = -1
|
||||
|
||||
|
||||
func reset_graph_control():
|
||||
for child in active_graph_control.get_children():
|
||||
active_graph_control.remove_child(child)
|
||||
@ -19,6 +20,7 @@ func reset_graph_control():
|
||||
|
||||
|
||||
func edit_animation_root_node(blt_node:BLTAnimationNode):
|
||||
print("Setting root node")
|
||||
graph_node_stack = []
|
||||
active_graph_edit_index = -1
|
||||
truncate_graph_stack(0)
|
||||
@ -31,6 +33,8 @@ func edit_animation_root_node(blt_node:BLTAnimationNode):
|
||||
edit_graph(blt_node)
|
||||
return
|
||||
|
||||
assert(is_instance_valid(animation_graph))
|
||||
|
||||
push_warning("Cannot edit node %s. Graph type %s not yet supported." % [blt_node.resource_name, blt_node.get_class()])
|
||||
|
||||
|
||||
|
||||
@ -105,12 +105,25 @@ func create_graph_node_for_blt_node(blt_node: BLTAnimationNode) -> GraphNode:
|
||||
result_graph_node.add_child(slot_label)
|
||||
result_graph_node.set_slot(i + result_slot_offset, true, 1, Color.WHITE, false, 1, Color.BLACK)
|
||||
|
||||
if blt_node.get_class() == "BLTAnimationNodeSampler":
|
||||
var animation_sampler_node:BLTAnimationNodeSampler = blt_node as BLTAnimationNodeSampler
|
||||
var animation_selector_button = OptionButton.new()
|
||||
var animation_player:AnimationPlayer = animation_sampler_node.get_animation_player()
|
||||
for animation_name in animation_player.get_animation_list():
|
||||
animation_selector_button.add_item(animation_name)
|
||||
if animation_name == animation_sampler_node.animation:
|
||||
animation_selector_button.select(animation_selector_button.item_count - 1)
|
||||
|
||||
animation_selector_button.item_selected.connect(_on_animation_select.bind(animation_sampler_node, animation_selector_button))
|
||||
|
||||
result_graph_node.add_child(animation_selector_button)
|
||||
|
||||
blt_node.node_changed.connect(_trigger_graph_changed)
|
||||
|
||||
return result_graph_node
|
||||
|
||||
|
||||
func _trigger_graph_changed():
|
||||
func _trigger_graph_changed(_node_name):
|
||||
graph_changed.emit()
|
||||
|
||||
|
||||
@ -253,3 +266,10 @@ func _on_node_double_click(graph_node:GraphNode):
|
||||
|
||||
if blend_tree_node is BLTAnimationNodeBlendTree:
|
||||
edit_subgraph.emit(blend_tree_node)
|
||||
|
||||
#
|
||||
# Animation selection for BltAnimationNodeSampler
|
||||
#
|
||||
func _on_animation_select(index:int, blt_node_sampler:BLTAnimationNodeSampler, option_button:OptionButton):
|
||||
blt_node_sampler.animation = option_button.get_item_text(index)
|
||||
blt_node_sampler.node_changed.emit(blt_node_sampler.resource_name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user