跳至正文
版本:最新版 - a1.133.x ⚖️

📺 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

ReturnsNameDescription
tableDeprojectScreenToWorld将 2D 屏幕坐标转换为 3D 世界空间位置
Vector2DGetMousePositionGets the current mouse screen location
floatGetViewportScaleGets the scale of viewport
Vector2DGetViewportSizeGets the size of viewport
Vector2DProjectWorldToScreen将 3D 世界空间向量转换为 2D 屏幕坐标
SetBloodScreenEnabledEnables/Disables the Blood Screen effect
SetBloodScreenIntensityManually sets the Blood Screen intensity
SetBrandingBarSettingsSets the Branding Bar settings (the bar with 'nanos world - closed alpha ver...')
SetCrosshairEnabledEnables/Disables the Crosshair
SetHardwareCursorLoads and sets a hardware cursor in the game from a PNG image
SetInteractionToolTipEnabledEnables/Disables the Interaction ToolTip
SetMousePositionSets the mouse position

DeprojectScreenToWorld

将 2D 屏幕坐标转换为 3D 世界空间位置

— Returns table (with this format).

local ret = Viewport.DeprojectScreenToWorld(screen_position)
TypeParameterDefaultDescription
Vector2Dscreen_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)
TypeParameterDefaultDescription
Vectorworld_position Required parameter 世界 3D 位置

SetBloodScreenEnabled

Enables/Disables the Blood Screen effect

Viewport.SetBloodScreenEnabled(is_enabled)
TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided

SetBloodScreenIntensity

If you want the Blood Screen to do not be overridden, disable it with Client.SetBloodScreenEnabled(false) before

Viewport.SetBloodScreenIntensity(intensity)
TypeParameterDefaultDescription
floatintensity 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?)
TypeParameterDefaultDescription
WidgetHorizontalAlignmenthorizontal_alignment Required parameter Left, Center and Right supported
WidgetVerticalAlignmentvertical_alignment Required parameter Bottom and Top supported
booleanis_lean?falseWhether to show less information

SetCrosshairEnabled

Enables/Disables the Crosshair

Viewport.SetCrosshairEnabled(is_enabled)
TypeParameterDefaultDescription
booleanis_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?)
TypeParameterDefaultDescription
CursorTypecursor_shape Required parameter No description provided
Image Pathcursor_path Required parameter a PNG image relative to Assets/
Vector2Dhotspot?Vector(0, 0)No description provided

SetInteractionToolTipEnabled

Enables/Disables the Interaction ToolTip

Viewport.SetInteractionToolTipEnabled(is_enabled)
TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided

SetMousePosition

Sets the mouse position

Viewport.SetMousePosition(new_position)
TypeParameterDefaultDescription
Vector2Dnew_position Required parameter No description provided

See also GetMousePosition.

🚀 Events

NameDescription
Resize当屏幕大小调整时调用

Resize

当屏幕大小调整时调用
Viewport.Subscribe("Resize", function(new_size)
-- Resize was called
end)
TypeArgumentDescription
Vector2Dnew_size新的新屏幕大小