Jump to content

Custom GUI using extern plugin


photo

Recommended Posts

I wanted to try our own GUI framework in Unigine.

The GUI engine would be running in our own custom dll, which would be interfaced with UnigineScript.

 

I see following possibility,

A new class which inherits "Widget Class", here we have setCallback, which would be user to set callbacks for "GUI_* variables in the Gui class".

Our dll would be linked using -extern_plugin

The dll can provide GUI picture in any defined format, so also suggest the structure of data, if required.

 

Can you guide to all the basic required callbacks to be set? and their function (just to be sure.)

Also note, we have Evaluation version only.

 

If there is any other way, please specify.

 

regards,

Link to comment

Check variables that are listed on this page and have "callback" in description.

 

Gui::GUI_ACTIVATED

Gui::GUI_CHANGED

Gui::GUI_CLICKED

Gui::GUI_DEACTIVATED

Gui::GUI_DOUBLE_CLICKED

Gui::GUI_DRAG_DROP

Gui::GUI_ENTER

Gui::GUI_FOCUS_IN

Gui::GUI_FOCUS_OUT

Gui::GUI_KEY_PRESSED

Gui::GUI_LEAVE

Gui::GUI_PRESSED

Gui::GUI_SHOW

 

There is two "buts", however.

* If you want to inherit a new user class (on UnigineScript) from Widget class in scripts, that would not be possible. User classes can be inherited only from user classes.

* If you want to inherit a C++ class from Widget in the Plugin, it also wont't be possible as plugins are not designed for drawing into engine viewport. (Well, if you have not implemented it yet).

 

It is better to use one of the following approaches:

* Flash (WidgetFlash) for user interfaces.

* With full source version you can modify the engine source code and create any custom widgets that use your GUI library.

Link to comment

Check variables that are listed on this page and have "callback" in description.

 

Gui::GUI_ACTIVATED

Gui::GUI_CHANGED

Gui::GUI_CLICKED

Gui::GUI_DEACTIVATED

Gui::GUI_DOUBLE_CLICKED

Gui::GUI_DRAG_DROP

Gui::GUI_ENTER

Gui::GUI_FOCUS_IN

Gui::GUI_FOCUS_OUT

Gui::GUI_KEY_PRESSED

Gui::GUI_LEAVE

Gui::GUI_PRESSED

Gui::GUI_SHOW

 

There is two "buts", however.

* If you want to inherit a new user class (on UnigineScript) from Widget class in scripts, that would not be possible. User classes can be inherited only from user classes.

* If you want to inherit a C++ class from Widget in the Plugin, it also wont't be possible as plugins are not designed for drawing into engine viewport. (Well, if you have not implemented it yet).

 

It is better to use one of the following approaches:

* Flash (WidgetFlash) for user interfaces.

* With full source version you can modify the engine source code and create any custom widgets that use your GUI library.

 

I understand.

But is it possible to have the an "memory picture" and then ask unigine script to draw it to view port.

I mean in option 2 of 'buts' plugin can not draw in unigine viewport, but it can provide the data to unigineScript and unigineScript can render the same to its view port.

How is GUI_SHOW used?

 

This is a basics of callbacks - you might find it useful. You are welcome to ask any questions!

 

Thanks, but I essentially want to draw in Unigine Gui/Viewport. But the above link does give a bit more understanding in callback system on unigine script.

Link to comment

But is it possible to have the an "memory picture" and then ask unigine script to draw it to view port.

I mean in option 2 of 'buts' plugin can not draw in unigine viewport, but it can provide the data to unigineScript and unigineScript can render the same to its view port.

You can try to use Unigine::Image to pass the picture from C++ side to script. After that, you can draw it with WidgetSprite or WidgetCanvas.

 

How is GUI_SHOW used?

 

Event GUI_SHOW is fired when Widget is added to Gui via addChild().

Link to comment

The point is, how to get "Unigine::Image" from c++ side, optimally.

 

There are 3 options of doing it:

1) Unigine::Image::set2D

which i think is not really optimized.

 

2) int copy(Ptr< Image > image, int x0, int y0, int x1, int y1, int width, int height)

Again how to get an image from c++ side in "Unigine::Image" format.

 

3) Unigine::Image::getPixels2DArray

 

Would try this if it is what i think.

 

Any more suggestions that would help me in this.

 

Thanks,

 

 

 

#only evaluation version with me!

Link to comment

You seem to need Unigine::Image::create2D.

 

Take a look at Memory Management article. There it is described how you can create objects on C++ side and different ways to pass them to the script. BTW, image is used as example :)

 

Usage Examples says that "UnigineScript can be easily extended through the Unigine API. Source code of examples is provided within all versions of Unigine (including the evaluation kit)."

 

But I think that we can not develop c++ plugin in "Evaluation Version", as there are no include folder at all.

Link to comment

But I think that we can not develop c++ plugin in "Evaluation Version", as there are no include folder at all.

You are right, access to C++ API is provided only in the binary and source versions of SDK.

Link to comment
×
×
  • Create New...