Jump to content

[SOLVED] Using callbacks/CallbackBase with UnigineScript


photo

Recommended Posts

Hi, there doesn't seem to be any documentation for this but is it possible to use callback.h/CallbackBase as a callback system for UnigineScript?

 

This thread seems to be the only thing covering it https://developer.unigine.com/forum/topic/2758-solved-callbacks/?hl=MakeCallbackObject#entry14925but there is no example of how to run the callback from another script. Is this possible?? We are trying here now but everything seems to require an object reference where the callback is to run.

 

(Game Framework is not an option)

 

Thanks!

Link to comment

Hi Taylor,

 

You can create callback without object with MakeCallback. As I understand you want something like this:

// script 1
namespace space1 {
	
	void some_func() {
		log.message("some_func");
	}
	
	Unigine::CallbackBase callback = Unigine::MakeCallback(functionid(space1::some_func));
	Unigine::CallbackBase getCallback() {
		return callback;
	}
}

// script 2
// #include <script 1>

namespace space2 {
	void run_callback() {
		Unigine::CallbackBase callback = space1::getCallback();
		callback.run();
	}
}
Link to comment
×
×
  • Create New...