Show play position of sub state machine
Sub state machine now show the play position of the current state playing.
This commit is contained in:
parent
9eb9335608
commit
771fbd282a
|
@ -876,7 +876,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
|
||||||
|
|
||||||
float len = MAX(0.0001, playback->get_current_length());
|
float len = MAX(0.0001, playback->get_current_length());
|
||||||
|
|
||||||
float pos = CLAMP(playback->get_current_play_pos(), 0, len);
|
float pos = CLAMP(play_pos, 0, len);
|
||||||
float c = pos / len;
|
float c = pos / len;
|
||||||
Color fg = get_color("font_color", "Label");
|
Color fg = get_color("font_color", "Label");
|
||||||
Color bg = fg;
|
Color bg = fg;
|
||||||
|
@ -1011,7 +1011,7 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
|
||||||
bool is_playing = false;
|
bool is_playing = false;
|
||||||
StringName current_node;
|
StringName current_node;
|
||||||
StringName blend_from_node;
|
StringName blend_from_node;
|
||||||
float play_pos = 0;
|
play_pos = 0;
|
||||||
|
|
||||||
if (playback.is_valid()) {
|
if (playback.is_valid()) {
|
||||||
tp = playback->get_travel_path();
|
tp = playback->get_travel_path();
|
||||||
|
@ -1046,6 +1046,25 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
|
||||||
state_machine_play_pos->update();
|
state_machine_play_pos->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if (current_node != StringName() && state_machine->has_node(current_node)) {
|
||||||
|
|
||||||
|
String next = current_node;
|
||||||
|
Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next);
|
||||||
|
Ref<AnimationNodeStateMachinePlayback> current_node_playback;
|
||||||
|
|
||||||
|
while (anodesm.is_valid()) {
|
||||||
|
current_node_playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback");
|
||||||
|
next += "/" + current_node_playback->get_current_node();
|
||||||
|
anodesm = anodesm->get_node(current_node_playback->get_current_node());
|
||||||
|
}
|
||||||
|
|
||||||
|
// when current_node is a state machine, use playback of current_node to set play_pos
|
||||||
|
if (current_node_playback.is_valid())
|
||||||
|
play_pos = current_node_playback->get_current_play_pos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (last_play_pos != play_pos) {
|
if (last_play_pos != play_pos) {
|
||||||
|
|
||||||
last_play_pos = play_pos;
|
last_play_pos = play_pos;
|
||||||
|
|
|
@ -160,6 +160,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin {
|
||||||
StringName last_current_node;
|
StringName last_current_node;
|
||||||
Vector<StringName> last_travel_path;
|
Vector<StringName> last_travel_path;
|
||||||
float last_play_pos;
|
float last_play_pos;
|
||||||
|
float play_pos;
|
||||||
|
|
||||||
float error_time;
|
float error_time;
|
||||||
String error_text;
|
String error_text;
|
||||||
|
|
Loading…
Reference in New Issue