Jump to content

Replacing engine.controls.setButtonReleaseCallback in version 2.16.1


photo

Recommended Posts

Hi all,

We're currently upgrading our codebase to be able to use the latest version of the Unigine SDK (2.16.1). And I've just realized that the Unigine::Controls::setButtonReleaseCallback function in no longer part of the Unigine SDK.

In C++, I could Unigine::Input::addCallback(Unigine::Input::CALLBACK_MOUSE_UP, Unigine::MakeCallback(...));. But in my case, this is implemented in UnigineScript, and it turns out that the addCallback function is not available in UnigineScript. Is there any workaround that adds an immediate callback upon a mouse event in UnigineScript without making an event filter function?

We are totally aware that the UnigineScript language is kind of deprecated and we aim to port all our existing scripts into C++, but first, we must port our current build to the latest version of the Unigine SDK.

Thanks in advance,

Karim

Link to comment

Hello,

The callback setup functions are still available in the script. Here is an example that works in version 2.16.1:

int on_button_press(int button)
{
	log.message("press: %d\n", button);
	return 0;
}

int on_button_release(int button)
{
	log.message("release: %d\n", button);
	return 0;
}

int init()
{
	engine.controls.setButtonPressCallback(functionid(on_button_press));
	engine.controls.setButtonReleaseCallback(functionid(on_button_release));

	return 1;
}

 

  • Thanks 1
Link to comment

Hi karpych11,

Thanks! I didn't know that this function still exists in the SDK.

If you search for "setButtonReleaseCallback" in the documentation, you won't get any results.

Link to comment
×
×
  • Create New...