ObjectGui Class
This class allows to create a flat GUI object that is positioned in the world and to which different widgets are assigned to be displayed. Basically, ObjectGui is a flat display to which a player can come to and click some buttons. GUI objects can undergo postprocessing filtering, for example, blurring or any other one.
When you create an instance of the ObjectGui class, it is automatically associated with an instance of the Gui class.
The following samples demonstrate the ObjectGui class usage:
ObjectGui Class
This class inherits from ObjectMembers
ObjectGui (float width, float height, string name = 0)
Constructor. Creates a new GUI object with given properties.Arguments
- float width - Physical width of the new GUI object in units.
- float height - Physical height of the new GUI object in units.
- string name - Path to the folder with GUI skin (the RC file and textures). If no value is specified, the default gui skin will be used.
int getBackground ()
Returns a value indicating if GUI background (black screen) is rendered.Return value
Positive number if background is rendered; otherwise, 0.float getControlDistance ()
Returns the distance, at which the GUI becomes controllable.Return value
Distance in units.int getDepthTest ()
Returns a value indicating if the GUI object uses depth test.Return value
1 if the GUI object uses depth test; otherwise, 0.Gui getGui ()
Returns a Gui instance associated with the object. This function is used when assigning a widget to the GUI object.When you create an instance of the ObjectGui class, it is automatically associated with a Gui instance.
Return value
GUI associated with the object.Examples
To get the GUI added via UnigineEditor and assign a widget to it, you can use the following:
// get the editor node named "ObjectGui_0" and cast it to ObjectGui
ObjectGui object_gui = class_cast("ObjectGui",engine.editor.getNodeByName("ObjectGui_0"));
// get a GUI associated with the object
Gui gui = object_gui.getGui();
// create a widget to be assigned
WidgetSpriteVideo sprite_video = new WidgetSpriteVideo(gui,"samples/objects/videos/sanctuary.ogv");
// add a new widget to the GUI
gui.addChild(sprite_video,GUI_ALIGN_EXPAND);
int getMouseShow ()
Returns a value indicating if the mouse cursor is rendered in the GUI object.Return value
1 if the cursor is rendered; otherwise, 0.float getPhysicalHeight ()
Returns the physical height of the GUI object.Return value
Height in units.float getPhysicalWidth ()
Returns the physical width of the GUI object.Return value
Width in units.float getPolygonOffset ()
Returns an offset of the GUI object above the background to avoid z-fighting.Return value
Polygon offset in units.int getScreenHeight ()
Returns the screen height of the GUI object.Return value
Height in pixels.int getScreenWidth ()
Returns the screen width of the GUI object.Return value
Width in pixels.int isBillboard ()
Returns a value indicating if the GUI object is a billboard.Return value
1 if GUI object is a billboard; otherwise, 0.void setBackground (int mode)
Sets a value indicating if the GUI background (black screen) should be rendered.Arguments
- int mode - Positive number to render GUI background, 0 to keep it transparent.
void setBillboard (int billboard)
Sets a value indicating if the GUI object should be a billboard.Arguments
- int billboard - Positive number to be a billboard; otherwise, 0.
void setControlDistance (float distance)
Sets a distance, at which the GUI becomes controllable.Arguments
- float distance - New distance in units. If a negative value is provided, 0 will be used instead.
void setDepthTest (int test)
Sets a value indicating if depth test should be used for the GUI object.Arguments
- int test - Positive number to use depth test; otherwise, 0.
void setMouseShow (int show)
Sets a value indicating if the mouse cursor should be rendered in the GUI object.Arguments
- int show - Positive number to render the mouse cursor; otherwise, 0.
void setPhysicalSize (float width, float height)
Sets physical dimensions of the GUI object.Arguments
- float width - New width in units. If a negative value is provided, 0 will be used instead.
- float height - New height in units. If a negative value is provided, 0 will be used instead.
void setPolygonOffset (float offset)
Sets an offset of the GUI object above the background to avoid z-fighting.Arguments
- float offset - Polygon offset in units. If a negative value is provided, 0 will be used instead.
void setScreenSize (int width, int height)
Sets screen dimensions of the GUI object.Arguments
- int width - New width in pixels. If a negative value is provided, 0 will be used instead.
- int height - New height in pixels. If a negative value is provided, 0 will be used instead.
Last update: 03.07.2017
Помогите сделать статью лучше
Была ли эта статья полезной?
(или выберите слово/фразу и нажмите Ctrl+Enter