[Feature Request] OnResume callback on ActionTask

NodeCanvas Forums Support [Feature Request] OnResume callback on ActionTask

This topic contains 3 replies, has 2 voices, and was last updated by  Gavalakis 1 month, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13260

    w
    Participant

    I have a custom ActionTask that drives audio/video playback. Is it possible to add an OnResume callback to the ActionTask script so that I can resume playback when the graph is unpaused? I guess I can determine playstate in OnUpdate loop myself but it’d be really handy if there’s a callback function i can directly use just like OnPause.

    Thanks

    #13263

    Gavalakis
    Keymaster

    Hello,

    For your information, when a graph resumes, the “OnExecute” method is called once again, where you can use it as a resume, possibly even doing some boolean check if required.
    Please let me know if that works for you, or if you need an explicit Resume call.

    Thanks.

    #13304

    w
    Participant

    An explicit resume callback would be extremely handy, as that enables us to resume timeline playback by subscribing to the event.
    I can modify the graph code to add the callback myself, but I’d prefer to leave the nodeCanvas package intact.

    #13306

    Gavalakis
    Keymaster

    Hello again,

    I will look into adding an explicit Resume callback. The problem with that though, would be that if I do, I will then also have to remove the OnExecute from being called when the action resumes (which is what happens now), and that might create problems with backwards compatibility, so I will have to make sure this does not happen 🙂
    Until that is done though, you can do something like this for example:

    
    using NodeCanvas.Framework;
    using ParadoxNotion.Design;
    
    namespace NodeCanvas.Tasks.Actions{
    
    	public class Example : ActionTask{
    
    		private bool paused;
    
    		protected override void OnExecute(){
    			if (paused){
    				paused = false;
    				//resume code...
    				return;
    			}
    
    			//normal code...
    		}
    
    		protected override void OnPause(){
    			paused = true;
    		}
    	}
    }
    

    Let me know what you think.
    Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.