📺 Viewport
Work with screen properties and effects.
🗿Static Class
This is a Static Class. Access it's methods directly with
.. It's not possible to spawn new instances.💂Authority
This static class can be accessed only on 🟧 Client side.
🧑💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!
🗿 Static Functions
| Returns | Name | Description | |
|---|---|---|---|
| table | DeprojectScreenToWorld | 将 2D 屏幕坐标转换为 3D 世界空间位置 | |
| Vector2D | GetMousePosition | Gets the current mouse screen location | |
| float | GetViewportScale | Gets the scale of viewport | |
| Vector2D | GetViewportSize | Gets the size of viewport | |
| Vector2D | ProjectWorldToScreen | 将 3D 世界空间向量转换为 2D 屏幕坐标 | |
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 |

DeprojectScreenToWorld
将 2D 屏幕坐标转换为 3D 世界空间位置
— Returns table (with this format).
local ret = Viewport.DeprojectScreenToWorld(screen_position)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector2D | screen_position | Required parameter | 屏幕位置 |

GetMousePosition
Gets the current mouse screen location
— Returns Vector2D (The current mouse screen location).
local ret = Viewport.GetMousePosition()
See also SetMousePosition.

GetViewportScale
Gets the scale of viewport
— Returns float (The scale of viewport).
local ret = Viewport.GetViewportScale()

GetViewportSize
Gets the size of viewport
— Returns Vector2D (The size of viewport).
local ret = Viewport.GetViewportSize()

ProjectWorldToScreen
将 3D 世界空间向量转换为 2D 屏幕坐标
— Returns Vector2D.
local ret = Viewport.ProjectWorldToScreen(world_position)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | world_position | Required parameter | 世界 3D 位置 |

SetBloodScreenEnabled
Enables/Disables the Blood Screen effect
Viewport.SetBloodScreenEnabled(is_enabled)
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled | Required parameter | No description provided |

SetBloodScreenIntensity
If you want the Blood Screen to do not be overridden, disable it with Client.SetBloodScreenEnabled(false) beforeViewport.SetBloodScreenIntensity(intensity)
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | intensity | Required parameter | From 0.0 to 1.0 |

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

SetCrosshairEnabled
Enables/Disables the Crosshair
Viewport.SetCrosshairEnabled(is_enabled)
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled | Required parameter | No description provided |

SetHardwareCursor
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?)
| Type | Parameter | Default | Description |
|---|---|---|---|
| CursorType | cursor_shape | Required parameter | No description provided |
| Image Path | cursor_path | Required parameter | a PNG image relative to Assets/ |
| Vector2D | hotspot? | Vector(0, 0) | No description provided |

SetInteractionToolTipEnabled
Enables/Disables the Interaction ToolTip
Viewport.SetInteractionToolTipEnabled(is_enabled)
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled | Required parameter | No description provided |

SetMousePosition
Sets the mouse position
Viewport.SetMousePosition(new_position)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector2D | new_position | Required parameter | No description provided |
See also GetMousePosition.
🚀 Events
| Name | Description | |
|---|---|---|
Resize | 当屏幕大小调整时调用 |

Resize
当屏幕大小调整时调用
Viewport.Subscribe("Resize", function(new_size)
-- Resize was called
end)
| Type | Argument | Description |
|---|---|---|
| Vector2D | new_size | 新的新屏幕大小 |