๐บ Viewport
Work with screen properties and effects
๐ฟ Static Functionsโ
DeprojectScreenToWorld: table | Transforms a 2D screen coordinates into 3D world-space location | |
GetMousePosition: Vector2D | Gets the current mouse screen location | |
GetViewportScale: float | Gets the scale of viewport | |
GetViewportSize: Vector2D | Gets the size of viewport | |
ProjectWorldToScreen: Vector2D | Transforms a 3D world-space vector into 2D screen coordinates | |
SetBloodScreenEnabled | Enables/Disables the Blood Screen effect | |
SetBloodScreenIntensity | Manually sets the Blood Screen intensity | |
SetBrandingBarSettings | Sets the Branding Bar settings (the bar with 'nanos world - closed alpha ver...') | |
SetCrosshairEnabled | Enables/Disables the Crosshair | |
SetHardwareCursor | Loads and sets a hardware cursor in the game from a PNG image | |
SetInteractionToolTipEnabled | Enables/Disables the Interaction ToolTip | |
SetMousePosition | Sets the mouse position | |
Subscribe: function | Subscribes to an Event | |
Unsubscribe | Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback |

DeprojectScreenToWorldModerateโ
Transforms a 2D screen coordinates into 3D world-space location
local ret = Viewport.DeprojectScreenToWorld(screen_position)
Parameters
| Name | Type | Description |
|---|---|---|
screen_position | Vector2D | Screen position |

GetMousePositionOptimalโ
Gets the current mouse screen location
local ret = Viewport.GetMousePosition()
Returns
| Type | Description |
|---|---|
| Vector2D | The current mouse screen location |
See also SetMousePosition.

GetViewportScaleOptimalโ
Gets the scale of viewport
local ret = Viewport.GetViewportScale()
Returns
| Type | Description |
|---|---|
| float | The scale of viewport |

GetViewportSizeOptimalโ
Gets the size of viewport
local ret = Viewport.GetViewportSize()
Returns
| Type | Description |
|---|---|
| Vector2D | The size of viewport |

ProjectWorldToScreenModerateโ
Transforms a 3D world-space vector into 2D screen coordinates
local ret = Viewport.ProjectWorldToScreen(world_position)
Parameters
| Name | Type | Description |
|---|---|---|
world_position | Vector | World 3D position |
Returns
| Type | Description |
|---|---|
| Vector2D | The screen position, in pixels |

SetBloodScreenEnabledOptimalโ
Enables/Disables the Blood Screen effect
Viewport.SetBloodScreenEnabled(is_enabled)
Parameters
| Name | Type | Description |
|---|---|---|
is_enabled | boolean | Whether to enable the Blood Screen effect |

SetBloodScreenIntensityOptimalโ
Manually sets the Blood Screen intensity
If you don't want the Blood Screen to be overridden by the default damage effect, disable it first with Viewport.SetBloodScreenEnabled(false)
Viewport.SetBloodScreenIntensity(intensity)
Parameters
| Name | Type | Description |
|---|---|---|
intensity | float | From 0.0 to 1.0 |

SetBrandingBarSettingsOptimalโ
Sets the Branding Bar settings (the bar with 'nanos world - closed alpha ver...')
Viewport.SetBrandingBarSettings(horizontal_alignment, vertical_alignment, is_lean?)
Parameters
| Name | Type | Description |
|---|---|---|
horizontal_alignment | WidgetHorizontalAlignment | Left, Center and Right supported |
vertical_alignment | WidgetVerticalAlignment | Bottom and Top supported |
is_lean? | boolean | Whether to show less information Default false |

SetCrosshairEnabledOptimalโ
Enables/Disables the Crosshair
Viewport.SetCrosshairEnabled(is_enabled)
Parameters
| Name | Type | Description |
|---|---|---|
is_enabled | boolean | Whether to enable the Crosshair |

SetHardwareCursorSlowโ
Loads and sets a hardware cursor in the game from a PNG image
Note: due an engine limitation modifying an already set cursor image will not change the cursor until the game is restarted
Viewport.SetHardwareCursor(cursor_shape, cursor_path, hotspot?)
Parameters
| Name | Type | Description |
|---|---|---|
cursor_shape | CursorType | Which cursor shape to replace |
cursor_path | Image Path | a PNG image relative to Assets/ |
hotspot? | Vector2D | Click point of the cursor image, in pixels Default Vector(0, 0) |

SetInteractionToolTipEnabledOptimalโ
Enables/Disables the Interaction ToolTip
Viewport.SetInteractionToolTipEnabled(is_enabled)
Parameters
| Name | Type | Description |
|---|---|---|
is_enabled | boolean | Whether to enable the Interaction ToolTip |

SetMousePositionOptimalโ
Sets the mouse position
Viewport.SetMousePosition(new_position)
Parameters
| Name | Type | Description |
|---|---|---|
new_position | Vector2D | The new mouse position |
See also GetMousePosition.

SubscribeOptimalโ
Subscribes to an Event
local ret = Viewport.Subscribe(event_name, callback)
Parameters
| Name | Type | Description |
|---|---|---|
event_name | string | Event to subscribe to |
callback | function | Callback to run on the event occurring |
Returns
| Type | Description |
|---|---|
| function | The function callback |

UnsubscribeOptimalโ
Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Viewport.Unsubscribe(event_name, callback?)
๐ Eventsโ
Resize | Called when the screen is resized |


