Skip to content

Viewport

Eduard Gushchin edited this page Jul 1, 2026 · 7 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.Viewport
Namespace Electron2D
Kind class
Category Rendering

Overview

Provides the Electron2D viewport node for 2D camera selection and canvas transforms.

Syntax

public class Electron2D.Viewport : Electron2D.Node

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Partial / Not verified
Out of profile: yes
Godot reference: Viewport

Runtime 2D viewport subset with current camera, visible rect, canvas transform, pixel snapping, root instance and input handled-state baseline.

Remarks

Electron2D 0.1.0 Preview uses Viewport as the concrete root node created by Electron2D.SceneTree. The public SceneTree.Root property remains typed as Electron2D.Node for the current object-model baseline.

Thread Safety

This type is not synchronized. Create and mutate viewports on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Camera2D

Members

Member Kind Summary
CanvasTransform Property Gets or sets the base transform applied to 2D canvas submission.
Size Property Gets or sets the viewport size in pixels.
Snap2DTransformsToPixel Property Gets or sets whether submitted 2D transforms snap to full pixels.
Snap2DVerticesToPixel Property Gets or sets whether submitted 2D destination rectangles snap to full pixels.
Electron2D.Viewport() Constructor Initializes a new instance of the Viewport type.
GetCamera2D() Method Gets the current active 2D camera.
GetTexture() Method Gets the dynamic texture that represents this viewport.
GetVisibleRect() Method Gets the visible viewport rectangle.
GuiGetHoveredControl() Method Gets the control currently under the GUI pointer.
SetInputAsHandled() Method Marks the input event currently being dispatched by this viewport as handled.

Member Details

CanvasTransform

Kind: Property

public Electron2D.Transform2D CanvasTransform { get; set; }

Summary

Gets or sets the base transform applied to 2D canvas submission.

Remarks

The active Electron2D.Camera2D transform is applied after this transform when internal sprite submission is built.

Value

The current canvas transform value.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Viewport

Size

Kind: Property

public Electron2D.Vector2I Size { get; set; }

Summary

Gets or sets the viewport size in pixels.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

The current size value.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Viewport

Snap2DTransformsToPixel

Kind: Property

public System.Boolean Snap2DTransformsToPixel { get; set; }

Summary

Gets or sets whether submitted 2D transforms snap to full pixels.

Remarks

Snapping affects internal render commands only. It does not mutate node transforms.

Value

The current snap2 dtransforms to pixel value.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Viewport

Snap2DVerticesToPixel

Kind: Property

public System.Boolean Snap2DVerticesToPixel { get; set; }

Summary

Gets or sets whether submitted 2D destination rectangles snap to full pixels.

Remarks

This is the command-level baseline for future GPU vertex snapping.

Value

The current snap2 dvertices to pixel value.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Viewport

Electron2D.Viewport()

Kind: Constructor

public Electron2D.Viewport()

Summary

Initializes a new instance of the Viewport type.

Remarks

The new instance follows the lifetime and validation rules of its declaring type.

Thread Safety

This member is not synchronized. Call it from the thread that owns the related object unless the declaring type states otherwise.

Since

This API is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Viewport

GetCamera2D()

Kind: Method

public Electron2D.Camera2D GetCamera2D()()

Summary

Gets the current active 2D camera.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Returns

The current Electron2D.Camera2D, or null when no camera is current.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Viewport

GetTexture()

Kind: Method

public Electron2D.ViewportTexture GetTexture()()

Summary

Gets the dynamic texture that represents this viewport.

Remarks

The returned texture reflects the current Electron2D.Viewport.Size when its metadata is queried. Electron2D 0.1.0 Preview exposes the Electron2D resource object before exposing public image readback or GPU handles.

Returns

A Electron2D.ViewportTexture bound to this viewport. The same instance is returned on later calls.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ViewportTexture

GetVisibleRect()

Kind: Method

public Electron2D.Rect2 GetVisibleRect()()

Summary

Gets the visible viewport rectangle.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Returns

A rectangle starting at Electron2D.Vector2.Zero with the current viewport size.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Viewport

GuiGetHoveredControl()

Kind: Method

public Electron2D.Control GuiGetHoveredControl()()

Summary

Gets the control currently under the GUI pointer.

Remarks

The value is updated during Electron2D.SceneTree.DispatchInput(Electron2D.InputEvent) when the dispatched event carries a pointer position.

Returns

The last visible control hit by mouse or touch input, or null when no control is currently hovered.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control.GetTooltip(Electron2D.Vector2)

SetInputAsHandled()

Kind: Method

public System.Void SetInputAsHandled()()

Summary

Marks the input event currently being dispatched by this viewport as handled.

Remarks

This method affects only the event that is currently moving through Electron2D.SceneTree.DispatchInput(Electron2D.InputEvent). The process-wide Electron2D.Input state has already been updated before user callbacks can call this method, so action state is not rolled back.

Calling this method when the viewport is not dispatching an input event has no effect.

Thread Safety

This method is not synchronized. Call it from the main scene thread while processing input for this viewport.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control.AcceptEvent
  • Electron2D.Node.GetViewport

Clone this wiki locally